public async Task <UpdateTreatmentResponse> UpdateTreatmentsAsync(UpdateTreatmentRequest request) { var response = new UpdateTreatmentResponse(); TreatmentEntity entity = await _treatmentRepository.GetTreatmentById(request.Id); if (entity == null) { response.StatusCode = (int)HttpStatusCode.NotFound; return(response); } entity.Description = request.Description; entity.Title = request.Title; var result = await _treatmentRepository.UpdateTreatmentsAsync(entity); if (result) { response.StatusCode = (int)HttpStatusCode.OK; } else { response.StatusCode = (int)HttpStatusCode.InternalServerError; _logger.LogError("An Error occurred"); } return(response); }
public async Task <IActionResult> UpdateTreatment([FromRoute] int id, [FromBody] UpdateTreatmentRequest request) { request = request ?? new UpdateTreatmentRequest(); request.Id = id; var response = await _treatmentService.UpdateTreatmentsAsync(request); return(GenerateResponse(response)); }