public ActionResult UpdateStudent(MultipleModel.StudentIndexModelVM request)
        {
            var messageList = new List<string>();

            if (ModelState.IsValid)
            {
                using (var db = new ElectionDbContext())
                {
                    var getStudent = db.Students.Find(request.UpdateUser.StudentId);
                    if (getStudent != null)
                    {
                        if(!(db.Students.Where(s => s.StudentNumber == request.UpdateUser.StudentNumber).Any()) || (getStudent.StudentNumber == request.UpdateUser.StudentNumber))
                        {
                            getStudent.StudentNumber = request.UpdateUser.StudentNumber;
                            getStudent.LastName = request.UpdateUser.LastName;
                            getStudent.FirstName = request.UpdateUser.FirstName;
                            getStudent.MiddleInitial = request.UpdateUser.MiddleInitial;
                            getStudent.Gender = request.UpdateUser.Gender;
                            getStudent.UpdatedAt = DateTime.Now;

                            db.Entry(getStudent).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();

                            request.Error = false;
                            string message = "You have successfully updated student (" + getStudent.StudentNumber + ")";
                            messageList.Add(message);
                            request.Message = messageList;
                            TempData["StudentIndexTD"] = request;
                            return RedirectToAction("StudentIndex", new { id = request.SectionId });
                        }
                        else if (db.Students.Where(s => s.StudentNumber == request.UpdateUser.StudentNumber).Any())
                        {
                            request.Error = true;
                            string message = "The student number "+ request.UpdateUser.StudentNumber+" is already existing!!";
                            messageList.Add(message);
                            request.Message = messageList;
                            TempData["StudentIndexTD"] = request;
                            return RedirectToAction("StudentIndex", new { id = request.SectionId });
                        }
                    }
                    else if (getStudent == null)
                    {
                        request.Error = true;
                        string message = "The selected student does not exist!!";
                        messageList.Add(message);
                        request.Message = messageList;
                        TempData["StudentIndexTD"] = request;
                        return RedirectToAction("StudentIndex", new { id = request.SectionId });
                    }
                }
            }
            request.Error = true;
            request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState);
            TempData["StudentIndexTD"] = request;
            return RedirectToAction("StudentIndex", new { id = request.SectionId });
        }
        public ActionResult UpdateCollege(MultipleModel.CollegeModelVM request)
        {
            var messageList = new List<string>();
            if (ModelState.IsValid)
            {
                using (var db = new ElectionDbContext())
                {
                    var colleges = db.Colleges.Find(request.UpdateCollege.CollegeId);

                    if (colleges != null)
                    {
                        if(!(db.Colleges.Where(c=>c.College == request.UpdateCollege.CollegeName).Any()))
                        {
                            colleges.College = request.UpdateCollege.CollegeName;
                            colleges.UpdatedAt = DateTime.Now;

                            db.Entry(colleges).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();

                            request.Error = false;
                            string message = "You have successfully updated " + colleges.College;
                            messageList.Add(message);
                            request.Message = messageList;
                            TempData["GroupsIndexTD"] = request.Error;
                            TempData["GroupsIndexTD"] = request.Message;

                            return RedirectToAction("GroupsIndex", "Admin");
                        }
                        else if(db.Colleges.Where(c => c.College == request.UpdateCollege.CollegeName).Any())
                        {
                            request.Error = true;
                            string message = request.UpdateCollege.CollegeName+" is already existing!!";
                            messageList.Add(message);
                            request.Message = messageList;
                            TempData["GroupsIndexTD"] = request;
                            return RedirectToAction("GroupsIndex", "Admin");
                        }

                    }
                    else if (colleges == null)
                    {
                        request.Error = true;
                        string message = "The selected college does not exist!!";
                        messageList.Add(message);
                        request.Message = messageList;
                        TempData["GroupsIndexTD"] = request;
                        return RedirectToAction("GroupsIndex", "Admin");
                    }
                }

            }
            request.Error = true;
            request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState);
            TempData["GroupsIndexTD"] = request;
            return RedirectToAction("GroupsIndex", "Admin");
        }
        public ActionResult UpdateSection(MultipleModel.SectionModelVM request)
        {
            var messageList = new List<string>();
            if (ModelState.IsValid)
            {
                using (var db = new ElectionDbContext())
                {
                    var section = db.Sections.Find(request.UpdateSection.SectionId);

                    if (section != null)
                    {
                        if (!(db.Sections.Where(m => m.Section == request.UpdateSection.SectionName).Any()))
                        {
                            section.Section = request.UpdateSection.SectionName;
                            section.UpdatedAt = DateTime.Now;

                            db.Entry(section).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();

                            request.Error = false;
                            string message = "You have successfully updated " + section.Section;
                            messageList.Add(message);
                            request.Message = messageList;
                            TempData["SectionIndexTD"] = request;
                            return RedirectToAction("SectionIndex", new { id = request.MajorId });
                        }
                        else if (db.Sections.Where(m => m.Section == request.UpdateSection.SectionName).Any())
                        {
                            request.Error = true;
                            string message = request.UpdateSection.SectionName + " is already existing!!";
                            messageList.Add(message);
                            request.Message = messageList;
                            TempData["SectionIndexTD"] = request;
                            return RedirectToAction("SectionIndex", new { id = request.MajorId });
                        }
                    }
                    else if (section == null)
                    {
                        request.Error = true;
                        string message = "The selected section does not exist!!";
                        messageList.Add(message);
                        request.Message = messageList;
                        TempData["SectionIndexTD"] = request;
                        return RedirectToAction("SectionIndex", new { id = request.MajorId });
                    }
                }

            }
            request.Error = true;
            request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState);
            TempData["SectionIndexTD"] = request;
            return RedirectToAction("SectionIndex", new { id = request.MajorId });
        }
        public ActionResult DeleteStudent(MultipleModel.StudentIndexModelVM request)
        {
            var messageList = new List<string>();

            if (ModelState.IsValid)
            {
                using (var db = new ElectionDbContext())
                {
                    var getStudent = db.Students.Find(request.DeleteStudent.StudentId);
                    if (getStudent != null)
                    {
                        getStudent.Deleted = true;
                        getStudent.UpdatedAt = DateTime.Now;

                        db.Entry(getStudent).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        request.Error = false;
                        string message = "You have successfully deleted student (" + getStudent.StudentNumber + ")";
                        messageList.Add(message);
                        request.Message = messageList;
                        TempData["StudentIndexTD"] = request;
                        return RedirectToAction("StudentIndex", new { id = request.SectionId });
                    }
                    else if (getStudent == null)
                    {
                        request.Error = true;
                        string message = "The selected student does not exist!!";
                        messageList.Add(message);
                        request.Message = messageList;
                        TempData["StudentIndexTD"] = request;
                        return RedirectToAction("StudentIndex", new { id = request.SectionId });
                    }
                }
            }
            request.Error = true;
            request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState);
            TempData["StudentIndexTD"] = request;
            return RedirectToAction("StudentIndex", new { id = request.SectionId });
        }