public async Task <TypedResult <PostCategoryDTO> > Update(UpdatePostCategory postCategory) { try { if (postCategory.Id.Equals(Guid.Empty)) { throw new InvalidOperationException(ErrorMessages.ID_IS_REQUIRED); } PostCategory existsRecord = await postCategoryRepo.FindById(postCategory.Id); if (existsRecord == null) { throw new InvalidOperationException(ErrorMessages.THIS_RECORD_DOES_NOT_EXISTS); } existsRecord.Title = postCategory.Title; PostCategory result = await postCategoryRepo.Update(existsRecord); return(new TypedResult <PostCategoryDTO>(_mapper.Map <PostCategoryDTO>(result))); } catch (Exception ex) { return(new TypedResult <PostCategoryDTO>(ex)); } }
public async Task <IActionResult> Put([FromBody] UpdatePostCategory model) { var result = await postCategoryServices.Update(model); if (result.Status) { return(Ok(result)); } return(BadRequest(result)); }