public async Task <OperationOutcome> AddRelatedPersonAsync(RelatedPersonModel model) { if (model.PersonId.GetValueOrDefault() == 0) { return(new OperationOutcome(false, GlobalResource.PersonIdIsNotDeclared)); } if (model.RelatedpersonId == model.PersonId.GetValueOrDefault()) { return(new OperationOutcome(false, GlobalResource.RelatedPersonCanNotBeSamePerson)); } if (await unitOfWork.RelatedRepository.ExistsRelation(model.PersonId.GetValueOrDefault(), model.RelatedpersonId)) { return(new OperationOutcome(false, GlobalResource.RelationHaveAlreadyExists)); } var relatedPersonDTO = mapper.Map <RelatedPersonModel, RelatedPerson>(model); await unitOfWork.RelatedRepository.AddAsync(relatedPersonDTO); return(await unitOfWork.CompleteAsync()); }
public async Task <IActionResult> AddRelatedPerson(RelatedPersonModel model) { return(Ok(await relatedPersonManager.AddRelatedPersonAsync(model))); }