public ActionResult Create([Bind(Include = "Id,BeginningDate,EndDate,Number,Year")] Semester semester)
        {
            if (ModelState.IsValid)
            {
                db.Semester.Add(semester);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(semester));
        }
Ejemplo n.º 2
0
        public ActionResult AddStudents(Students student)
        {
            if (ModelState.IsValid)
            {
                using (DiaryConnection db = new DiaryConnection())
                {
                    db.Students.Add(student);
                    db.SaveChanges();
                }
                return(RedirectToAction("Students"));
            }
            ViewBag.ErrorMessage = "Неверный ввод данных";
            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", student.Groups1);
                }
            }
            return(View(student));
        }
Ejemplo n.º 3
0
        public ActionResult CompletionStudentRegistration(int?applicationId, int?studentId)
        {
            if (applicationId == null || studentId == null)
            {
                return(HttpNotFound());
            }
            DiaryConnection db          = new DiaryConnection();
            var             application = db.ApplicationsForRegistration.Find(applicationId);

            ViewBag.FoundStudents = db.Students.Where(p => (p.FullName.Contains(application.FirstName) && p.FullName.Contains(application.SecondName)) || p.Number == application.CardNumber);
            var student = db.Students.Find(studentId);
            ApplicationDbContext context = new ApplicationDbContext();
            var userManager    = new ApplicationUserManager(new UserStore <ApplicationUser>(context));
            var studentAccount = new ApplicationUser {
                Email = application.Email, UserName = application.Login
            };
            var result = userManager.Create(studentAccount, application.Password);

            if (result.Succeeded)
            {
                userManager.AddToRole(studentAccount.Id, "student");
                student.UserName = application.Login;
                db.ApplicationsForRegistration.Remove(application);
                db.SaveChanges();
            }
            return(RedirectToAction("ApplicationsForRegistration"));
        }
Ejemplo n.º 4
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));
 }
Ejemplo n.º 5
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));
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
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));
 }
Ejemplo n.º 8
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));
 }
Ejemplo n.º 9
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"));
 }
Ejemplo n.º 10
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));
 }
Ejemplo n.º 11
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"));
 }
Ejemplo n.º 12
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"));
 }
Ejemplo n.º 13
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"));
 }
Ejemplo n.º 14
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"));
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 16
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"));
 }
Ejemplo n.º 17
0
 public ActionResult AddLecturerGroupSubject([Bind(Include = "Id,GroupId,TeacherId,SubjectId")] TeachersGroupsSubjects lgs)
 {
     using (DiaryConnection db = new DiaryConnection())
     {
         if (ModelState.IsValid)
         {
             db.TeachersGroupsSubjects.Add(lgs);
             db.SaveChanges();
             return(RedirectToAction("LecturerGroupSubject"));
         }
         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(lgs));
 }
        public ActionResult StudentRegister(StudentRegisterViewModel viewModel)
        {
            ApplicationsForRegistration application = new ApplicationsForRegistration
            {
                FirstName   = viewModel.FirstName,
                SecondName  = viewModel.SecondName,
                MiddleName  = viewModel.MiddleName,
                CardNumber  = viewModel.CardNumber,
                DateOfBirth = viewModel.DateOfBirth,
                GroupId     = viewModel.GroupId,
                Email       = viewModel.Email,
                Login       = viewModel.Login,
                Password    = viewModel.Password
            };

            using (DiaryConnection db = new DiaryConnection())
            {
                db.ApplicationsForRegistration.Add(application);
                db.SaveChanges();
            }
            return(RedirectToAction("ApplicationAccepted"));
        }
Ejemplo n.º 19
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"));
 }