public ClassExams Add(ClassExams entity) { var instuteID = Convert.ToInt32(Membership.GetUser().PasswordQuestion); entity.InstituteID = instuteID; return(rep.Add(entity)); }
public ActionResult Details(int id = 0) { ClassExams ClassExams = rep.GetById(id); if (ClassExams == null) { return(HttpNotFound()); } return(View(ClassExams)); }
public ActionResult Edit(int id = 0) { var instuteID = Convert.ToInt32(Membership.GetUser().PasswordQuestion); ClassExams classobj = rep.GetById(id); if (classobj == null || Convert.ToInt32(classobj.InstituteID) != instuteID || classobj.Deleted == true) { return(HttpNotFound()); } return(View(classobj)); }
public ActionResult DeleteConfirmed(int id) { var instuteID = Convert.ToInt32(Membership.GetUser().PasswordQuestion); ClassExams classobj = rep.GetById(id); if (classobj == null || Convert.ToInt32(classobj.InstituteID) != instuteID || classobj.Deleted == true) { return(HttpNotFound()); } rep.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ClassID,ExamNamesID,TotalMarks")] ClassExams ClassExams) { if (ModelState.IsValid) { if (rep.CheckIfExists(ClassExams.ClassID, ClassExams.ExamNamesID)) { ModelState.AddModelError(string.Empty, "Exam Already Exists"); ViewBag.ClassID = new SelectList(repClasses.GetAll(), "Id", "Name"); ViewBag.ExamNamesID = new SelectList(repExamNames.GetAll(), "Id", "Name"); return(View(ClassExams)); } rep.Add(ClassExams); return(RedirectToAction("Index")); } ViewBag.ClassID = new SelectList(repClasses.GetAll(), "Id", "Name"); ViewBag.ExamNamesID = new SelectList(repExamNames.GetAll(), "Id", "Name"); return(View(ClassExams)); }
public ActionResult Edit([Bind(Include = "Id,TotalMarks")] ClassExams ClassExams) { if (ModelState.IsValid) { var instuteID = Convert.ToInt32(Membership.GetUser().PasswordQuestion); ClassExams Exams = db.ClassExams.Find(ClassExams.Id); if (Exams == null || Convert.ToInt32(Exams.InstituteID) != instuteID || Exams.Deleted == true) { return(HttpNotFound()); } if (!rep.CheckIfExists(Exams.ClassID, Exams.ExamNamesID)) { ModelState.AddModelError(string.Empty, "Data Doesn't Exists"); return(View(ClassExams)); } Exams.TotalMarks = ClassExams.TotalMarks; db.Entry(Exams).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ClassExams)); }
public void Update(ClassExams entity) { db.ClassExams.Attach(entity); db.Entry(entity).Property(x => x.TotalMarks).IsModified = true; db.SaveChanges(); }