Ejemplo n.º 1
0
        public async Task <Confirmation> Record(InvolvedPartyCommand command)
        {
            // Load the existing occurrence for which the involved party should be recorded.
            var occurrence = await _occurenceRepo.ReadOccurrenceAsync(command.OccurrenceId);

            if (occurrence == null)
            {
                return(new Confirmation
                {
                    ResultMessage = "Invalid Occurrence"
                });
            }

            InvolvedParty involvedParty = CreateParty(command);

            ValidationResultSet valResultSet = _validation.Validate(involvedParty);

            if (valResultSet.IsInvalid)
            {
                return(new Confirmation
                {
                    Validations = valResultSet.ObjectValidations
                });
            }

            occurrence.AddInvolvedParty(involvedParty);

            // Update the occurrence within the repository.
            await _occurenceRepo.UpdateOccurrenceAsync(occurrence);

            return(new Confirmation
            {
                OccurrenceId = occurrence.OccurrenceId
            });
        }
Ejemplo n.º 2
0
        // Create contact for party and associate with the involved automobile.
        private static InvolvedParty CreateParty(InvolvedPartyCommand command)
        {
            var contact = Contact.IdentifiedAs(command.FirstName, command.LastName, command.DateOfBirth)
                          .InsuredBy(command.InsuranceCompany, command.PolicyNumber, command.InsuredState)
                          .PrimaryContactInfo(command.PhoneNumber);

            return(InvolvedParty.IdentifiedBy(contact, command.Vin));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ReportInvolvedParty(string occurrenceId,
                                                              [FromBody] InvolvedPartyCommand command)
        {
            command.OccurrenceId = occurrenceId;

            Confirmation confirmation = await _messaging.SendAsync(command);

            if (confirmation.Validations.Empty())
            {
                Ok(confirmation);
            }

            return(BadRequest(confirmation));
        }