public async Task <IActionResult> Edit(int id, Saller saller) { if (!ModelState.IsValid) { var departments = await _departmentService.FindAllAsync(); var viewModel = new SellerFormViewModel { Departments = departments, Saller = saller }; return(View(viewModel)); } if (id != saller.Id) { return(RedirectToAction(nameof(Error), new { message = "Id mismatch" })); } try { await _sallerService.UpdateAsync(saller); return(RedirectToAction(nameof(Index))); } catch (NotFoundException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } catch (DbConcurrencyExceprion dbE) { return(RedirectToAction(nameof(Error), new { message = dbE.Message })); } catch (ApplicationException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } }
public async Task <IActionResult> Edit(int Id, Saller saller) { if (!ModelState.IsValid) { var departments = await _departmentService.FindAllAsync(); var viewModels = new SallerFromViewModel { Saller = saller, Departments = departments }; return(View(viewModels)); } if (Id != saller.Id) { return(BadRequest()); } try { await _sallerService.UpdateAsync(saller); return(RedirectToAction(nameof(Index))); } catch (NotFoundException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } catch (DbConcurrencyException e) { return(RedirectToAction(nameof(Error), new { message = e.Message })); } }