public async Task <IActionResult> Edit(int id) { var level = await _repository.GetLevel(id); if (level == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } return(View(level)); }
public async Task <IActionResult> Edit(int id, TypeOfProduct typeOfProduct) { if (id != typeOfProduct.Id) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } if (ModelState.IsValid) { try { _repository.Update <TypeOfProduct>(typeOfProduct); await _repository.SavaAll(); } catch (DbUpdateConcurrencyException) { if (_repository.GetLevel(typeOfProduct.Id) == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(typeOfProduct)); }