コード例 #1
0
 public ActionResult EditLecturers([Bind(Include = "Id,FullName,Departament")] Teachers lecturer)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Entry(lecturer).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Lecturers"));
         }
     }
     return(View(lecturer));
 }
コード例 #2
0
 public ActionResult EditSubjects([Bind(Include = "Id,Name,Departament")] Subjects subject)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Entry(subject).State = EntityState.Modified;
             db.SaveChanges();
             //RedirectToAction("Subjects");
         }
     }
     return(RedirectToAction("Subjects"));//View(subject);
 }
コード例 #3
0
 public ActionResult AddSubjects([Bind(Include = "Id,Name,Departament")] Subjects subject)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Subjects.Add(subject);
             db.SaveChanges();
             return(RedirectToAction("Subjects"));
         }
     }
     return(View(subject));
 }
コード例 #4
0
        public ActionResult DeleteStudent(int id)
        {
            Students student;

            using (DiaryConnection db = new DiaryConnection())
                student = db.Students.Find(id);
            if (student == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(student));
        }
コード例 #5
0
        public ActionResult ConfirmStudentRegistration(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            ApplicationsForRegistration application;
            DiaryConnection             db = new DiaryConnection();

            application           = db.ApplicationsForRegistration.Find(id);
            ViewBag.FoundStudents = db.Students.Where(p => (p.FullName.Contains(application.FirstName) && p.FullName.Contains(application.SecondName)) || p.Number == application.CardNumber).ToList();
            return(View(application));
        }
コード例 #6
0
 public ActionResult EditSemester([Bind(Include = "Id,BeginningDate,EndDate,Number,Year")] Semester semester)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Entry(semester).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Semesters"));
         }
     }
     return(View(semester));
 }
コード例 #7
0
 public ActionResult AddLecturers([Bind(Include = "Id,FullName,Departament")] Teachers lecturer)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Teachers.Add(lecturer);
             db.SaveChanges();
             return(RedirectToAction("AddLecturers"));
         }
     }
     return(View(lecturer));
 }
コード例 #8
0
 public ActionResult DeleteGroupConfirmed(int id)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         Groups group = db.Groups.Find(id);
         if (group == null)
         {
             return(HttpNotFound());
         }
         db.Groups.Remove(group);
         db.SaveChanges();
     }
     return(RedirectToAction("Groups"));
 }
コード例 #9
0
 public ActionResult AddGroups([Bind(Include = "Id,Number,YearOfAdmission,Faculty,Degree,FormOfStudy,MonitorId")] Groups groups)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Groups.Add(groups);
             db.SaveChanges();
             return(RedirectToAction("Groups"));
         }
     }
     ViewBag.ErrorMessage = "Неверный ввод данных";
     return(View(groups));
 }
コード例 #10
0
 public ActionResult DeleteApplicationsForRegistrationConfirmed(int id)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         ApplicationsForRegistration application = db.ApplicationsForRegistration.Find(id);
         if (application == null)
         {
             return(HttpNotFound());
         }
         db.ApplicationsForRegistration.Remove(application);
         db.SaveChanges();
     }
     return(RedirectToAction("ApplicationsForRegistration"));
 }
コード例 #11
0
 public ActionResult DeleteLecturerGroupSubjectConfirmed(int id)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         TeachersGroupsSubjects lgs = db.TeachersGroupsSubjects.Find(id);
         if (lgs == null)
         {
             return(HttpNotFound());
         }
         db.TeachersGroupsSubjects.Remove(lgs);
         db.SaveChanges();
     }
     return(RedirectToAction("LecturerGroupSubject"));
 }
コード例 #12
0
 //регистрация
 public ActionResult ApplicationsForRegistration()
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         var groups = db.Groups.ToList();
         foreach (var b in groups)
         {
             b.Number = b.GetGroupNumber(Semester.Today());
         }
         Groups nullGroup = new Groups();
         ViewBag.Groups = new SelectList(groups, "Id", "Number", new Groups());
     }
     return(View());
 }
コード例 #13
0
 public ActionResult DeleteLecturerConfirmed(int id)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         Teachers lecturer = db.Teachers.Find(id);
         if (lecturer == null)
         {
             return(HttpNotFound());
         }
         db.Teachers.Remove(lecturer);
         db.SaveChanges();
     }
     return(RedirectToAction("Lecturers"));
 }
コード例 #14
0
 public ActionResult DeleteSemesterConfirmed(int id)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         Semester semester = db.Semester.Find(id);
         if (semester == null)
         {
             return(HttpNotFound());
         }
         db.Semester.Remove(semester);
         db.SaveChanges();
     }
     return(RedirectToAction("Semesters"));
 }
コード例 #15
0
 public ActionResult DeleteSubjectsConfirmed(int id)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         Subjects subject = db.Subjects.Find(id);
         if (subject == null)
         {
             return(HttpNotFound());
         }
         db.Subjects.Remove(subject);
         db.SaveChanges();
     }
     return(RedirectToAction("Subjects"));
 }
コード例 #16
0
        public ActionResult AddStudents()
        {
            List <Groups> groups = new List <Models.Groups>();

            using (DiaryConnection db = new DiaryConnection())
            {
                groups = db.Groups.ToList();
                foreach (var b in groups)
                {
                    b.Number       = b.GetGroupNumber(Semester.Today());
                    ViewBag.Groups = new SelectList(groups, "Id", "Number");
                }
            }
            return(View());
        }
コード例 #17
0
        public ActionResult ApplicationsForRegistrationSearch(string firstName, string secondName, string middleName, string number, int?group)
        {
            List <ApplicationsForRegistration> appl = null;
            DiaryConnection db = new DiaryConnection();

            if (group == null)
            {
                appl = db.ApplicationsForRegistration.Where(p => p.FirstName.Contains(firstName) && p.SecondName.Contains(secondName) && p.CardNumber.Contains(number) && p.MiddleName.Contains(middleName) && p.CardNumber.Contains(number)).ToList();
            }
            else
            {
                appl = db.ApplicationsForRegistration.Where(p => p.FirstName.Contains(firstName) && p.SecondName.Contains(secondName) && p.CardNumber.Contains(number) && p.MiddleName.Contains(middleName) && p.CardNumber.Contains(number) && p.GroupId == group).ToList();
            }
            return(View(appl));
        }
コード例 #18
0
 public ActionResult AddLecturerGroupSubject()
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         var groups = db.Groups.ToList();
         foreach (var b in groups)
         {
             b.Number = b.GetGroupNumber(Semester.Today());
         }
         ViewBag.Groups    = new SelectList(groups, "Id", "Number");
         ViewBag.Lecturers = new SelectList(db.Teachers.ToList(), "Id", "FullName");
         ViewBag.Subjects  = new SelectList(db.Subjects.ToList(), "Id", "Name");
     }
     return(View());
 }
コード例 #19
0
        public ActionResult EditSubjects(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Subjects subject;

            using (DiaryConnection db = new DiaryConnection())
                subject = db.Subjects.Find(id);
            if (subject != null)
            {
                return(View(subject));
            }
            return(HttpNotFound());
        }
コード例 #20
0
        public ActionResult EditLecturers(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Teachers lecturer;

            using (DiaryConnection db = new DiaryConnection())
                lecturer = db.Teachers.Find(id);
            if (lecturer != null)
            {
                return(View(lecturer));
            }
            return(HttpNotFound());
        }
コード例 #21
0
        public ActionResult EditSemester(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Semester semester;

            using (DiaryConnection db = new DiaryConnection())
                semester = db.Semester.Find(id);
            if (semester != null)
            {
                return(View(semester));
            }
            return(HttpNotFound());
        }
コード例 #22
0
        public ActionResult StudentsSearchForApplication(string number, string fullName, string groupNumber, int applicationId)
        {
            List <Students> foundStudents;

            using (DiaryConnection db = new DiaryConnection())
            {
                if (number == "" && fullName == "" && groupNumber == "")
                {
                    foundStudents = db.Students.ToList();
                }
                else if (fullName == "" && groupNumber == "")
                {
                    foundStudents = db.Students.Where(p => p.Number == number).ToList();
                }
                else if (number == "" && groupNumber == "")
                {
                    foundStudents = db.Students.Where(p => p.FullName.Contains(fullName)).ToList();
                }
                else if (number == "" && fullName == "")
                {
                    var students = db.Students.ToList();
                    foundStudents = students.Where(p => p.Groups1.GetGroupNumber(Semester.Today()) == Convert.ToInt32(groupNumber)).ToList();
                }
                else if (groupNumber == null)
                {
                    foundStudents = db.Students.Where(p => p.Number == number && p.FullName.Contains(fullName)).ToList();
                }
                else if (number == "")
                {
                    foundStudents = db.Students.Where(p => p.FullName.Contains(fullName)).ToList().
                                    Where(p => p.Groups1.GetGroupNumber(Semester.Today()) == Convert.ToInt32(groupNumber)).ToList();
                }
                else if (fullName == "")
                {
                    foundStudents = db.Students.Where(p => p.Number == number).ToList().
                                    Where(p => p.Groups1.GetGroupNumber(Semester.Today()) == Convert.ToInt32(groupNumber)).ToList();
                }
                else
                {
                    foundStudents = db.Students.Where(p => p.Number == number && p.FullName.Contains(fullName)).ToList().
                                    Where(p => p.Groups1.GetGroupNumber(Semester.Today()) == Convert.ToInt32(groupNumber)).ToList();
                }
                foundStudents.RemoveAll(p => p.UserName != null);
            }
            ViewBag.ApplicationId = applicationId;
            return(PartialView(foundStudents));
        }
コード例 #23
0
        public ActionResult DeleteLecturer(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Teachers lecturer;

            using (DiaryConnection db = new DiaryConnection())
                lecturer = db.Teachers.Find(id);
            if (lecturer == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(lecturer));
        }
コード例 #24
0
        public ActionResult DeleteLecturerGroupSubject(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            TeachersGroupsSubjects lgs;
            DiaryConnection        db = new DiaryConnection();

            lgs = db.TeachersGroupsSubjects.Find(id);
            if (lgs == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(lgs));
        }
コード例 #25
0
        public ActionResult DeleteSemester(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Semester semester;

            using (DiaryConnection db = new DiaryConnection())
                semester = db.Semester.Find(id);
            if (semester == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(semester));
        }
コード例 #26
0
        public ActionResult DeleteApplicationsForRegistration(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            ApplicationsForRegistration application;
            DiaryConnection             db = new DiaryConnection();

            application = db.ApplicationsForRegistration.Find(id);
            if (application == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(application));
        }
コード例 #27
0
        public ActionResult DeleteGroups(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Groups group;

            using (DiaryConnection db = new DiaryConnection())
                group = db.Groups.Find(id);
            if (group == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(group));
        }
コード例 #28
0
        public ActionResult DeleteSubjects(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Subjects subject;

            using (DiaryConnection db = new DiaryConnection())
                subject = db.Subjects.Find(id);
            if (subject == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = id;
            return(View(subject));
        }
コード例 #29
0
 public ActionResult EditGroups([Bind(Include = "Id,Number,YearOfAdmission,Faculty,Degree,FormOfStudy,MonitorId")] Groups group)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Entry(group).State = EntityState.Modified;
             db.SaveChanges();
         }
         else
         {
             var students = db.Students.Where(p => p.GroupId == group.Id);
             ViewBag.Students = new SelectList(students, "Id", "FullName", group.Students);
             db.Dispose();
             return(View(group));
         }
     }
     return(RedirectToAction("Groups"));
 }
コード例 #30
0
        public ActionResult ShowStudents(int?id)
        {
            Groups          group;
            List <Students> students;

            if (id == null)
            {
                return(HttpNotFound());
            }
            using (DiaryConnection db = new DiaryConnection())
            {
                group = db.Groups.Find(id);
                if (group == null)
                {
                    return(HttpNotFound());
                }
                students = group.Students1.ToList();
            }
            return(View(students));
        }