public async Task <IActionResult> Edit(int id) { var college = await _repository.GetCollege(id); if (college == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } return(View(college)); }
public async Task <IActionResult> Edit(int id, WjhaaMessage wjhaaMessage) { if (id != wjhaaMessage.Id) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } if (ModelState.IsValid) { try { _repository.Update <WjhaaMessage>(wjhaaMessage); await _repository.SavaAll(); } catch (DbUpdateConcurrencyException) { if (_repository.GetCollege(wjhaaMessage.Id) == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CountryId"] = new SelectList(await _repository.GetCountries(), "Id", "Name", wjhaaMessage.CountryId); ViewData["MGuideId"] = new SelectList(await _repository.GetGuides(), "Id", "Name", wjhaaMessage.MGuideId); ViewData["TypesMessageId"] = new SelectList(await _repository.GetTypesMessages(), "Id", "Name", wjhaaMessage.TypesMessageId); return(View(wjhaaMessage)); }