Example #1
0
        public ActionResult EditLecturerGroupSubject(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            TeachersGroupsSubjects lgs;
            DiaryConnection        db = new DiaryConnection();

            lgs = db.TeachersGroupsSubjects.Find(id);
            if (lgs != null)
            {
                var groups = db.Groups.ToList();
                foreach (var b in groups)
                {
                    b.Number = b.GetGroupNumber(Semester.Today());
                }
                ViewBag.Groups    = new SelectList(groups, "Id", "Number", lgs.Groups);
                ViewBag.Lecturers = new SelectList(db.Teachers.ToList(), "Id", "FullName", lgs.Teachers);
                ViewBag.Subjects  = new SelectList(db.Subjects.ToList(), "Id", "Name", lgs.Subjects);
                db.Dispose();
                return(View(lgs));
            }
            db.Dispose();
            return(HttpNotFound());
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Example #3
0
        public ActionResult EditStudents(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Students        student;
            DiaryConnection db = new DiaryConnection();

            student = db.Students.Find(id);
            if (student != null)
            {
                List <Groups> groups = db.Groups.ToList();
                foreach (var b in groups)
                {
                    b.Number       = b.GetGroupNumber(Semester.Today());
                    ViewBag.Groups = new SelectList(groups, "Id", "Number", student.Groups1);
                }
                db.Dispose();
                return(View(student));
            }
            db.Dispose();
            return(HttpNotFound());
        }
Example #4
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"));
 }
Example #5
0
        public ActionResult EditGroups(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Groups group;

            using (DiaryConnection db = new DiaryConnection())
            {
                group = db.Groups.Find(id);
                if (group != null)
                {
                    var students = db.Students.Where(p => p.GroupId == group.Id).ToList();
                    ViewBag.Students = new SelectList(students, "Id", "FullName", group.Students);
                    db.Dispose();
                    return(View(group));
                }
            }
            return(HttpNotFound());
        }
Example #6
0
 public ActionResult EditStudents([Bind(Include = "Id,FullName,Number,YearOfBirth,GroupId,Email")] Students student)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.Entry(student).State = EntityState.Modified;
             db.SaveChanges();
         }
         else
         {
             List <Groups> groups = db.Groups.ToList();
             foreach (var b in groups)
             {
                 b.Number = b.GetGroupNumber(Semester.Today());
             }
             ViewBag.Groups = new SelectList(groups, "Id", "Number");
             db.Dispose();
             ViewBag.ErrorMessage = "Неверный ввод данных";
             View(student);
         }
     }
     return(RedirectToAction("Students"));
 }