public async Task <IActionResult> AddIdentifier(Guid id, [FromBody] IdentifierModel dto) { if (dto == null) { return(BadRequest()); } var Identifier = _mapper.Map <Identifier>(dto); var person = _personRepository.Get(id).FirstOrDefault(); if (person != null) { //if (_personRepository.IsIdentifierExist(Identifier.IdentifierType.GetEnumDisplayName())) if (_personRepository.IsIdentifierExistToPerson(id, Convert.ToInt32(Identifier.IdentifierType))) { return(NotFound(new ApiResponse(404, $"IDENTIFIER is already added to person"))); } _personRepository.AddIdentifierToPerson(id, Identifier); await _personRepository.SaveChangesAsync(); return(CreatedAtRoute("GetPerson", new { ID = person.ID }, _mapper.Map <PersonModel>(person))); } return(BadRequest()); }