public async Task <IActionResult> Edit(int id, JobNotable jobNotable) { if (id != jobNotable.Id) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } if (ModelState.IsValid) { try { _repository.Update <JobNotable>(jobNotable); await _repository.SavaAll(); } catch (DbUpdateConcurrencyException) { if (_repository.GetJobNotable(jobNotable.Id) == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TypeNotableId"] = new SelectList(await _repository.GetTypeNotables(), "Id", "Name", jobNotable.TypeNotableId); return(View(jobNotable)); }
public async Task <IActionResult> Create(JobNotable jobNotable) { if (ModelState.IsValid) { _repository.Add <JobNotable>(jobNotable); await _repository.SavaAll(); return(RedirectToAction(nameof(Index))); } ViewData["TypeNotableId"] = new SelectList(await _repository.GetTypeNotables(), "Id", "Name", jobNotable.TypeNotableId); return(View(jobNotable)); }