public async Task <IActionResult> Put(int id, [FromBody] MergePersonDto mergePersonDto) { if (id == 0 || mergePersonDto.Id == 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0.")); } return(await SaveAndReturnEntityAsync(async() => await _mergePersonService.SaveAndReturnEntityAsync(mergePersonDto))); }
public async Task <IActionResult> Post([FromBody] MergePersonDto mergePersonDto) { if (mergePersonDto.Id != 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted.")); } return(await SaveAndReturnEntityAsync(async() => await _mergePersonService.SaveAndReturnEntityAsync(mergePersonDto))); }
public async Task <BaseEntity> SaveAndReturnEntityAsync(MergePersonDto entityDto) { var mergePersonDb = _mapper.Map <MergePerson>(entityDto); mergePersonDb = ValidateMergePerson(mergePersonDb); if (string.IsNullOrWhiteSpace(entityDto.ErrorMessage)) { var result = await _repository.SaveAndReturnEntityAsync(mergePersonDb); return(result); } return(mergePersonDb); }
public async Task <int> SaveAsync(MergePersonDto mergePerson) { var result = await SaveAndReturnEntityAsync(mergePerson); return(result.Id); }