public async Task<IActionResult> Edit(EditJobCategoryViewModel model) { if (!ModelState.IsValid) { return View(model); } try { var jobCategory = await _context.JobCategories .SingleOrDefaultAsync(m => m.JobCategoryId == model.JobCategoryId); jobCategory.Name = model.Name; _context.Update(jobCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await JobCategoryExists(model.JobCategoryId)) { return View("NotFound"); } throw; } return RedirectToAction(nameof(Index)); }
public async Task <IActionResult> Edit(EditJobCategoryViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var category = _mapper.Map <JobCategory>(model); var result = await _jobCategoryService.Edit(category); if (result) { return(RedirectToAction(nameof(Index))); } return(View("NotFound")); }