public async Task <IActionResult> Edit([FromBody] EditOperationRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var response = await _operationService.EditAsync(request); if (!response.IsValid) { return(BadRequest(response.Message)); } return(Ok(response)); }
public async Task <BaseResponse> EditAsync(EditOperationRequest request) { var operation = await _operationRepository.GetAsync(operation => operation.Id == request.Id); if (operation == null) { return(new BaseResponse("Operation is not found")); } operation.Date = request.Date; operation.Description = request.Description; operation.Amount = request.Amount; operation.CategoryId = request.CategoryId; _operationRepository.Update(operation); await _unitOfWork.SaveChangesAsync(); return(new BaseResponse()); }