public async Task <IActionResult> Add([FromBody] AddIdentifierViewModel model) { var response = new ApiResponseModel(); if (model == null) { response.Message = "Identifier body can not be empty."; return(BadRequest(response)); } if (model.Type <= 0) { response.Message = "Invalid identifier type."; return(BadRequest(response)); } if (model.PersonId == null) { response.Message = "Invalid person id."; return(BadRequest(response)); } if (string.IsNullOrEmpty(model.Value)) { response.Message = "Identifier value can not be empty."; return(BadRequest(response)); } try { var domainModel = Mapper.Map <IdentifierModel>(model); response.Data = await _identifierService.AddIdentifierToPerson(domainModel); response.Status = Status.SUCCESS; response.Message = "Added!"; return(Ok(response)); } catch (PersonNotFoundException) { response.Message = "Person with given id not found."; return(NotFound(response)); } catch { response.Message = "Unknown error. Please, contact support team."; return(StatusCode(500, response)); } }