Exemple #1
0
        public ClassExams Add(ClassExams entity)
        {
            var instuteID = Convert.ToInt32(Membership.GetUser().PasswordQuestion);

            entity.InstituteID = instuteID;
            return(rep.Add(entity));
        }
Exemple #2
0
        public ActionResult Details(int id = 0)
        {
            ClassExams ClassExams = rep.GetById(id);

            if (ClassExams == null)
            {
                return(HttpNotFound());
            }
            return(View(ClassExams));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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"));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
 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));
 }
Exemple #7
0
 public void Update(ClassExams entity)
 {
     db.ClassExams.Attach(entity);
     db.Entry(entity).Property(x => x.TotalMarks).IsModified = true;
     db.SaveChanges();
 }