public ActionResult DeleteConfirmed(int id) { CourseYear courseYear = db.CourseYears.Find(id); db.CourseYears.Remove(courseYear); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CourseYearId,Year")] CourseYear courseYear) { if (ModelState.IsValid) { db.Entry(courseYear).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(courseYear)); }
public ActionResult Create([Bind(Include = "CourseYearId,Year")] CourseYear courseYear) { if (ModelState.IsValid) { db.CourseYears.Add(courseYear); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(courseYear)); }
// GET: CourseYears/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseYear courseYear = db.CourseYears.Find(id); if (courseYear == null) { return(HttpNotFound()); } return(View(courseYear)); }
public IActionResult CourseYearRegistration(CourseYearRegistrationViewModel model) { if (ModelState.IsValid) { CourseYear courseYear = new CourseYear { YearTitle = model.YearTitle, YearNumberRepresentation = model.YearNumberRepresentation }; entityRepository.Insert(courseYear); entityRepository.Save(); TempData["created"] = $"Admin { model.YearTitle }, was created successfully."; return(RedirectToAction("allregisteredcourseyears")); } return(View(model)); }
public IActionResult UpdateCourseYear(UpdateCourseYearViewModel model) { if (ModelState.IsValid) { CourseYear courseYear = entityRepository.GetById(model.Id); if (courseYear == null) { ViewBag.ErrorMessage = $"The course year with Id = { model.Id } could not be found"; return(View("NotFound")); } courseYear.YearTitle = model.YearTitle; courseYear.YearNumberRepresentation = model.YearNumberRepresentation; entityRepository.Update(courseYear); entityRepository.Save(); TempData["edited"] = $"Year { model.YearTitle }, was updated successfully."; return(Json(new { success = true })); } return(PartialView(model)); }
public IActionResult DeleteCourseYear(long Id) { if (Id.Equals(0)) { ViewBag.ErrorMessage = $"The Faculty with Reference Id = { Id } could not be found"; return(View("NotFound")); } else { CourseYear courseYear = entityRepository.GetById(Id); if (courseYear == null) { ViewBag.ErrorMessage = $"The course Year with Reference Id = { Id } could not be found"; return(View("NotFound")); } string course_year = courseYear.YearTitle; entityRepository.Delete(courseYear.Id); entityRepository.Save(); TempData["deleted"] = $"Year { course_year }, was permanently deleted"; return(Json(new { success = true })); } }
public IActionResult UpdateCourseYear(long Id) { if (Id.Equals(0)) { ViewBag.ErrorMessage = $"The course year resource with Id = { Id } could not be found"; return(View("NotFound")); } CourseYear courseYear = entityRepository.GetById(Id); if (courseYear == null) { ViewBag.ErrorMessage = $"The course year with Id = { Id } could not be found"; return(View("NotFound")); } UpdateCourseYearViewModel model = new UpdateCourseYearViewModel { Id = courseYear.Id, YearTitle = courseYear.YearTitle, YearNumberRepresentation = courseYear.YearNumberRepresentation }; return(PartialView(model)); }
public override int GetHashCode() { return(CourseName.GetHashCode() ^ CourseYear.GetHashCode()); }