public ActionResult Edit(Classroom classroom)
        {
            bool   roomAlready  = true;
            string errorMessage = String.Empty;

            if (ModelState.IsValid)
            {
                //check if such classroom isn't in DB
                roomAlready = Checking(classroom);

                if (roomAlready)
                {
                    Classroom r = db.Classrooms.Find(classroom.Room_ID);
                    ((IObjectContextAdapter)db).ObjectContext.Detach(r);

                    db.Entry(classroom).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            errorMessage = "Аудиторія " + classroom.Number + " є в базі даних";
            ModelState.AddModelError(string.Empty, errorMessage);
            return(View(classroom));
        }
Beispiel #2
0
        public ActionResult CorrectRecordPost(Grade grade)
        {
            if (ModelState.IsValid)
            {
                db.Entry(grade).State = EntityState.Modified;
                db.SaveChanges();
            }

            var gr = db.Grades.Include(g => g.Schedule).Include(g => g.Student);

            gr = from s in gr
                 where s.Schedule_ID == grade.Schedule_ID
                 orderby s.Student.Surname
                 select s;

            return(PartialView("_Grades", gr));
        }
Beispiel #3
0
        public ActionResult Edit(Teacher teacher)
        {
            bool   already = false;
            string error   = string.Empty;

            if (ModelState.IsValid)
            {
                already = Checking(teacher);

                if (already)
                {
                    Teacher r = db.Teachers.Find(teacher.Teacher_ID);
                    ((IObjectContextAdapter)db).ObjectContext.Detach(r);

                    db.Entry(teacher).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            error = "Викладач " + teacher.Surname + " " + teacher.Name + " " + teacher.LastName + " є в базі даних";
            ModelState.AddModelError(string.Empty, error);
            return(View(teacher));
        }
Beispiel #4
0
        public ActionResult Edit(Subject subject)
        {
            bool   already = true;
            string error   = string.Empty;

            if (ModelState.IsValid)
            {
                already = Checking(subject);

                if (already)
                {
                    Subject r = db.Subjects.Find(subject.Subject_ID);
                    ((IObjectContextAdapter)db).ObjectContext.Detach(r);

                    db.Entry(subject).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            error = "Предмет " + subject.Name + " є в базі даних";
            ModelState.AddModelError(string.Empty, error);
            return(View(subject));
        }
Beispiel #5
0
        public ActionResult Edit(Group group)
        {
            bool   groupAlready = true;
            string errorMessage = String.Empty;

            if (ModelState.IsValid)
            {
                groupAlready = Checking(group);
                if (groupAlready)
                {
                    Group r = db.Groups.Find(group.Group_ID);
                    ((IObjectContextAdapter)db).ObjectContext.Detach(r);

                    db.Entry(group).State = EntityState.Modified;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            errorMessage = "Група " + group.Name + " " + group.EnrollmentYear + " є в базі даних";
            ModelState.AddModelError(string.Empty, errorMessage);
            return(View(group));
        }
Beispiel #6
0
        public ActionResult Edit(LessonType lessontype)
        {
            bool   already = true;
            string error   = string.Empty;

            if (ModelState.IsValid)
            {
                already = Checking(lessontype);

                if (already)
                {
                    LessonType r = db.LessonTypes.Find(lessontype.Lesson_ID);
                    ((IObjectContextAdapter)db).ObjectContext.Detach(r);

                    db.Entry(lessontype).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            error = "Тип заняття " + lessontype.Type + " є в базі даних";
            ModelState.AddModelError(string.Empty, error);
            return(View(lessontype));
        }
Beispiel #7
0
        public ActionResult Edit(Student student)
        {
            bool   already = true;
            string error   = string.Empty;

            if (ModelState.IsValid)
            {
                already = Checking(student);

                if (already)
                {
                    Student r = db.Students.Find(student.Student_ID);
                    ((IObjectContextAdapter)db).ObjectContext.Detach(r);

                    db.Entry(student).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            error = "Студент " + student.Surname + " " + student.Name + " " + student.LastName + " є в базі даних";
            ModelState.AddModelError(string.Empty, error);
            ViewBag.Group_ID = new SelectList(db.Groups, "Group_ID", "Name", student.Group_ID);
            return(View(student));
        }