public async Task <IActionResult> Create([Bind("Id,AcademicYear,Semester,FromDate,ToDate,UserId")] SchedulingTripHead schedulingTripHead) { if (ModelState.IsValid) { _context.Add(schedulingTripHead); await _context.SaveChangesAsync(); _f.Flash("success", "تم الحفظ بنجاح"); return(RedirectToAction(nameof(Index))); } ViewData["AcademicYear"] = new SelectList(_context.AcademicYears, "Name", "Name"); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", schedulingTripHead.UserId); return(View(schedulingTripHead)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,AcademicYear,Semester,FromDate,ToDate,UserId")] SchedulingTripHead schedulingTripHead) { if (id != schedulingTripHead.Id) { Response.StatusCode = 404; return(View("SchedulingTripHeadsNotFound")); } if (ModelState.IsValid) { _context.Update(schedulingTripHead); _f.Flash("success", "تم التعديل بنجاح"); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Semester"] = new SelectList(SemesterList(), "Name", "Name", schedulingTripHead.Semester); ViewData["AcademicYear"] = new SelectList(_context.AcademicYears, "Name", "Name", schedulingTripHead.AcademicYear); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", schedulingTripHead.UserId); return(View(schedulingTripHead)); }