public async Task <IActionResult> UpdateModel(UpdateGenerationDto updateGeneration) { ServiceResponse <Generation> response = await _generationService.Update(updateGeneration); if (response.Data == null) { return(NotFound(response)); } return(Ok(response)); }
public async Task <ServiceResponse <Generation> > Update(UpdateGenerationDto updateGeneration) { ServiceResponse <Generation> serviceResponse = new ServiceResponse <Generation>(); try { var updatedGeneration = _context.Generations.FirstOrDefault(m => m.Id == updateGeneration.Id); updatedGeneration.Name = updatedGeneration.Name; _context.SaveChanges(); serviceResponse.Data = updatedGeneration; } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message; } return(serviceResponse); }