public async Task <ActionResult <UpdateMakeDto> > UpdateVehicleMake(UpdateMakeDto updatedMake) { try { var targetMake = await _context.VehicleMakes.Where(make => make.Id == updatedMake.Id).SingleOrDefaultAsync(); _context.Entry(targetMake).CurrentValues.SetValues(updatedMake); await _context.SaveChangesAsync(); return(updatedMake); } catch (InvalidOperationException ex) { return(null); } }
public async Task <IActionResult> UpdateMake(UpdateMakeDto updatedVehicleMake) { var crudAction = CRUDActions.Update; if (ModelState.IsValid) { await _vehicleAdministrationService.UpdateVehicleMake(updatedVehicleMake); return(RedirectToAction("ReadMake", new { id = updatedVehicleMake.Id })); } else { var messageType = FeedbackMessageType.Failed; var failedCreateViewModel = new CreateMakeViewModel() { MessageType = messageType, MessageText = FeedbackMessageBase.CRUDMessage(messageType, crudAction, updatedVehicleMake.Name) }; return(View("~/Views/Administration/VehicleMake/EditMake.cshtml", updatedVehicleMake)); } }