public async Task <IActionResult> Edit(EditJobTypeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { var jobType = await _context.JobTypes .SingleOrDefaultAsync(m => m.JobTypeId == model.JobTypeId); jobType.Name = model.Name; _context.Update(jobType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobTypeExists(model.JobTypeId)) { return(View("NotFound")); } throw; } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(EditJobTypeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var type = _mapper.Map <JobType>(model); var result = await _jobTypeService.Edit(type); if (result) { return(RedirectToAction(nameof(Index))); } return(View("NotFound")); }