Пример #1
0
        public ActionResult DeleteRange(int[] deleteInputs)
        {
            if (deleteInputs != null && deleteInputs.Length > 0)
            {
                for (int j = 0; j < deleteInputs.Length; j++)
                {
                    int        index   = deleteInputs[j];
                    StudentMVC student = db.StudentsMVC.Find(index);
                    db.StudentsMVC.Remove(student);
                    var listMap = new List <StudentsManagement.Models.Mapping>();
                    listMap = db.Mappings.Where(i => i.StudentID == index).ToList();
                    var tempSub = new StudentsManagement.Models.Subject();

                    foreach (var item in listMap)
                    {
                        tempSub = db.Subjects.Find(item.SubjectID);
                        tempSub.SubjectCurrentNumber -= 1;
                        db.Mappings.Remove(item);
                    }
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #2
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit([Bind(Include = "StudentID,StudentName,StudentAge,StudentGrade,StudentYearOfGraduation")] StudentMVC student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "StudentID,StudentName,StudentAge,StudentGrade,StudentYearOfGraduation")] StudentMVC student)
        {
            // var student = new Student();
            if (ModelState.IsValid)
            {
                db.StudentsMVC.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
Пример #4
0
        // GET: /Student/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentMVC student = db.StudentsMVC.Find(id);

            if (student == null)
            {
                return(HttpNotFound());
            }
            return(View(student));
        }
Пример #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            StudentMVC student = db.StudentsMVC.Find(id);

            db.StudentsMVC.Remove(student);

            var listMap = new List <StudentsManagement.Models.Mapping>();

            listMap = db.Mappings.Where(i => i.StudentID == id).ToList();
            var tempSub = new StudentsManagement.Models.Subject();

            foreach (var item in listMap)
            {
                tempSub = db.Subjects.Find(item.SubjectID);
                tempSub.SubjectCurrentNumber -= 1;
                db.Mappings.Remove(item);
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }