addRequest: initial implementation
addRequest-specific unit tests now all pass: ok 55 - addRequest: dies if supporterId not specified. ok 56 - addRequest: dies if requestTypeId / requestType not specified. ok 57 - addRequest: dies if supporterId invalid. ok 58 - addRequest: dies if requestTypeId invalid. ok 59 - addRequest: succeeds with a requestType but no configuration parameter. ok 60 - addRequest: id returned on successful addRequest() is a number ok 61 - addRequest: underlying call to addRequestType works properly, per getRequestType ok 62 - addRequest: succeeds with a requestType and requestConfiguration and a note. ok 63 - addRequest: succeeds with a requestTypeId and requestConfigurationId with no a note.
This commit is contained in:
		
							parent
							
								
									d654622ebe
								
							
						
					
					
						commit
						cb01c1a14c
					
				
					 1 changed files with 16 additions and 0 deletions
				
			
		|  | @ -504,9 +504,25 @@ sub addRequest($$) { | |||
|   my $supporterId = $params->{supporterId}; | ||||
|   die "addRequest: supporterId, \"$supporterId\" not found in supporter database" | ||||
|     unless $self->_verifyId($supporterId); | ||||
| 
 | ||||
|   $self->_beginWork; | ||||
|   $self->_getOrCreateRequestType($params); | ||||
|   $self->_getOrCreateRequestConfiguration($params) if (defined $params->{requestConfiguration} or | ||||
|                                                        defined $params->{requestConfigurationId}); | ||||
| 
 | ||||
|   # After those two calls above, I know I have requestTypeId and | ||||
|   # requestConfigurationId are accurate.  Note that | ||||
|   # $params->{requestConfigurationId} can be undef, which is permitted in the | ||||
|   # database schema. | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   my $sth = $self->dbh->prepare("INSERT INTO request(supporter_id, request_type_id, request_configuration_id, notes, date_requested) " . | ||||
|                                              "VALUES(?,            ?,               ?,                        ?,      date('now'))"); | ||||
|   $sth->execute($supporterId, $params->{requestTypeId}, $params->{requestConfigurationId}, $params->{notes}); | ||||
|   my $id = $self->dbh->last_insert_id("","","",""); | ||||
|   $self->_commit; | ||||
|   return $id; | ||||
| } | ||||
| ###################################################################### | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Bradley M. Kuhn
						Bradley M. Kuhn