public ActionResult AddNewClass()
 {
     UserServices services = new UserServices();
     ClassModel model = new ClassModel();
     model.Nauczyciele = services.GetTeachers();
     return View(model);
 }
 public ActionResult DeleteClass(int IdKlasy)
 {
     UserServices services = new UserServices();
     ClassModel model = new ClassModel();
     model = services.GetClass(IdKlasy);
     return View(model);
 }
 public ActionResult AddNewStudent()
 {
     StudentModel model = new StudentModel();
     UserServices ServiceForUser = new UserServices();
     model.Oddziały = ServiceForUser.GetClasses();
     return View(model);
 }
        public ActionResult EditTeacher()
        {
            HttpCookie loggedTeacher = Request.Cookies["LoggedUser"];
            TeacherModel teacher = new TeacherModel();
            UserServices services = new UserServices();

            teacher = services.GetTeacher(loggedTeacher.Values.Get("Login"));
            return View(teacher);
        }
 public ActionResult CreateCourse()
 {
     CourseModel model = new CourseModel();
     CourseServices ServiceForCourses = new CourseServices();
     UserServices ServicesForUsers = new UserServices();
     model.Subjects = ServiceForCourses.GetSubjects();
     model.Classes = ServicesForUsers.GetClasses();
     return View(model);
 }
        public ActionResult EditStudent()
        {
            HttpCookie loggedStudent = Request.Cookies["LoggedUser"];
            StudentModel student = new StudentModel();
            UserServices services = new UserServices();

            student = services.GetStudent(loggedStudent.Values.Get("Login"));
            student.Oddziały = services.GetClasses();
            return View(student);
        }
 public ActionResult CreateCourse(CourseModel newCourse)
 {
     CourseServices CourseServ = new CourseServices();
     UserServices UserServ = new UserServices();
     HttpCookie loggedTeacher = Request.Cookies["LoggedUser"];
     TeacherModel teacher = UserServ.GetTeacher(loggedTeacher.Values.Get("Login"));
     newCourse.TeacherId = teacher.IdNauczyciela;
     CourseServ.NewCourse(newCourse);
     return RedirectToAction("Index", "Teacher");
 }
        public ActionResult EditStudent(StudentModel model)
        {
            HttpCookie loggedStudent = Request.Cookies["LoggedUser"];
            UserServices services = new UserServices();
            StudentModel student = services.GetStudent(loggedStudent.Values.Get("Login"));
            services.ChangePassword(student.Login, student.Name, student.Surname, model.Password);

            UserLoginModel logged = new UserLoginModel();
            logged.Login = student.Login;
            logged.Name = student.Name;
            logged.Surname = student.Surname;
            return RedirectToAction("Index",logged);
        }
        public ActionResult EditTeacher(TeacherModel model)
        {
            HttpCookie loggedTeacher = Request.Cookies["LoggedUser"];
            UserServices services = new UserServices();
            TeacherModel teacher = services.GetTeacher(loggedTeacher.Values.Get("Login"));
            services.ChangePassword(teacher.Login, teacher.Imię, teacher.Nazwisko, model.Hasło);

            UserLoginModel logged = new UserLoginModel();
            logged.Login = model.Login;
            logged.Name = model.Imię;
            logged.Surname = model.Nazwisko;
            return RedirectToAction("Index", logged);
        }
 public ActionResult AddNewStudent(StudentModel model)
 {
     UserServices ServiceForUser = new UserServices();
     if (ServiceForUser.GetStudent(model.Login) == null)
     {
         ViewBag.Message = String.Empty;
         ServiceForUser.CreateNewStudent(model);
         return RedirectToAction("Index", "DatabaseAction");
     }
     else
     {
         ViewBag.Message = "Istnieje już uczeń o podanym loginie";
         return RedirectToAction("AddNewStudent", "DatabaseAction");
     }
 }
 public ActionResult Index(UserLoginModel model)
 {
     LoggedUserModel user = new LoggedUserModel();
     UserServices services = new UserServices();
     if(Session["zalogowany"] != null && Request.Cookies["LoggedUser"] !=null && model.Login == null && model.Password == null)
     {
         user.Login = Request.Cookies["LoggedUser"].Values.Get("Login");
         user.Name = Request.Cookies["LoggedUser"].Values.Get("Name");
         user.Surname = Request.Cookies["LoggedUser"].Values.Get("Surname");
     }
     else
     {
         user.Login = model.Login;
         user.Name = model.Name;
         user.Surname = model.Surname;
     }
     return View(user);
 }
Exemplo n.º 12
0
        public SolutionModel GetSolution(int SolutionId)
        {
            var           query = db.Rozwiązania.Where(x => x.IdRozwiązania == SolutionId).FirstOrDefault();
            UserServices  us    = new UserServices();
            SolutionModel model = new SolutionModel {
                SolutionId = query.IdRozwiązania,
                StudentId  = query.IdUcznia,
                TaskId     = query.IdZadania,
                Solution   = query.TreśćRozwiązania,
                FileName   = query.NazwaPliku,
                Extension  = query.Rozszerzenie,
                Comment    = query.Komentarz,
                Note       = query.Ocena,
                Student    = us.GetStudent(query.IdUcznia),
                Notes      = GetPossibleNotes()
            };

            return(model);
        }
Exemplo n.º 13
0
        public ActionResult Index()
        {
            UserServices service = new UserServices();

            if (Request.Cookies.Get("LoggedUser") != null)
            {

                UserLoginModel model = service.GetLoggedUser(Request.Cookies.Get("LoggedUser").Values.Get("Login"));
                if(Session["zalogowany"]!= null)
                    if (service.ExistsStudentInDatabase(Request.Cookies.Get("LoggedUser").Values.Get("Login"), Request.Cookies.Get("LoggedUser").Values.Get("Name"), Request.Cookies.Get("LoggedUser").Values.Get("Surname")))
                    {
                        return RedirectToAction("Index", "Student", model);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Teacher", model);
                    }
            }
            return View();
        }
Exemplo n.º 14
0
        public ActionResult Index(string Login, string Password)
        {
            UserServices service = new UserServices();
            UserLoginModel model = service.GetLoggedUser(Login, Password);

            if (model != null)
            {
                Session["zalogowany"] = model;
                LoggedUserModel user = new LoggedUserModel();
                user.Name = model.Name;
                user.Surname = model.Surname;
                user.Login = model.Login;
                HttpCookie cookie = new HttpCookie("LoggedUser");
                cookie.Values.Add("Name",model.Name);
                cookie.Values.Add("Surname",model.Surname);
                cookie.Values.Add("Login",model.Login);

                if (service.ExistsStudentInDatabase(user.Login, user.Name, user.Surname))
                {
                    cookie.Values.Add("Role", "S");
                    cookie.Expires = DateTime.Now.AddDays(1.0);
                    Response.Cookies.Add(cookie);
                    return RedirectToAction("Index", "Student", user);
                }
                else
                {
                    cookie.Values.Add("Role", "T");
                    cookie.Expires = DateTime.Now.AddDays(1.0);
                    Response.Cookies.Add(cookie);
                    return RedirectToAction("Index", "Teacher", user);
                }
            }
            else
            {
                ViewBag.Message = "Nie istnieje użytkownik o podanych danych logowania, spróbuj ponownie";
                return View();
            }
        }
Exemplo n.º 15
0
        public List <SolutionModel> GetSolutions(int TaskId)
        {
            var query = db.Rozwiązania.Where(x => x.IdZadania == TaskId).ToList();
            List <SolutionModel> solutions = new List <SolutionModel>();
            UserServices         us        = new UserServices();

            foreach (var item in query)
            {
                var uczen = db.Uczniowie.Where(x => x.IdUcznia == item.IdUcznia).FirstOrDefault();
                solutions.Add(new SolutionModel
                {
                    TaskId     = item.IdZadania,
                    StudentId  = item.IdUcznia,
                    SolutionId = item.IdRozwiązania,
                    Solution   = item.TreśćRozwiązania,
                    FileName   = item.NazwaPliku,
                    Extension  = item.Rozszerzenie,
                    Comment    = item.Komentarz,
                    Note       = (byte?)item.Ocena,
                    Student    = us.GetStudent(item.IdUcznia)
                });
            }
            return(solutions);
        }
 public ActionResult DeleteStudent(int IdUcznia)
 {
     UserServices ServicesForUser = new UserServices();
     StudentModel model = new StudentModel();
     model = ServicesForUser.GetStudent(IdUcznia);
         return View(model);
 }
 public ActionResult DeleteStudent(StudentModel model)
 {
     UserServices ServicesForUser = new UserServices();
     ServicesForUser.DeleteStudent(model);
     return RedirectToAction("ManageStudents");
 }
Exemplo n.º 18
0
 public SolutionModel GetSolution(int SolutionId)
 {
     var query = db.Rozwiązania.Where(x => x.IdRozwiązania == SolutionId).FirstOrDefault();
     UserServices us = new UserServices();
     SolutionModel model = new SolutionModel{
         SolutionId = query.IdRozwiązania,
         StudentId = query.IdUcznia,
         TaskId = query.IdZadania,
         Solution = query.TreśćRozwiązania,
         FileName = query.NazwaPliku,
         Extension = query.Rozszerzenie,
         Comment = query.Komentarz,
         Note = query.Ocena,
         Student = us.GetStudent(query.IdUcznia),
         Notes = GetPossibleNotes()
     };
     return model;
 }
 public ActionResult DeleteClass(ClassModel model)
 {
     UserServices services = new UserServices();
     services.DeleteClass(model);
     return RedirectToAction("ManageClasses");
 }
Exemplo n.º 20
0
 public List<SolutionModel> GetSolutions(int TaskId)
 {
     var query = db.Rozwiązania.Where(x => x.IdZadania == TaskId).ToList();
     List<SolutionModel> solutions = new List<SolutionModel>();
     UserServices us = new UserServices();
     foreach (var item in query)
     {
         var uczen = db.Uczniowie.Where(x => x.IdUcznia == item.IdUcznia).FirstOrDefault();
         solutions.Add(new SolutionModel
         {
             TaskId = item.IdZadania,
             StudentId = item.IdUcznia,
             SolutionId = item.IdRozwiązania,
             Solution = item.TreśćRozwiązania,
             FileName = item.NazwaPliku,
             Extension = item.Rozszerzenie,
             Comment = item.Komentarz,
             Note = (byte?)item.Ocena,
             Student = us.GetStudent(item.IdUcznia)
         });
     }
     return solutions;
 }
 public ActionResult AddNewTeacher(TeacherModel model)
 {
     UserServices service = new UserServices();
     service.CreateNewTeacher(model.Login,model.Hasło,model.Imię,model.Nazwisko);
     return RedirectToAction("ManageTeachers","DatabaseAction");
 }
 public ActionResult ManageTeachers()
 {
     UserServices service = new UserServices();
     List<TeacherModel> teachers = new List<TeacherModel>();
     teachers = service.GetTeachers();
     return View(teachers);
 }
 public ActionResult EditClass(int IdKlasy)
 {
     UserServices services = new UserServices();
     ClassModel klasa = new ClassModel();
     klasa = services.GetClass(IdKlasy);
     return View(klasa);
 }
 public ActionResult ManageClasses()
 {
     UserServices services = new UserServices();
     List<ClassModel> classes = new List<ClassModel>();
     classes = services.GetClasses();
     return View(classes);
 }
 public ActionResult ManageStudents()
 {
     UserServices service = new UserServices();
     List<StudentModel> students = new List<StudentModel>();
     students = service.GetStudents();
     return View(students);
 }
 public ActionResult EditTeacher(TeacherModel model)
 {
     UserServices service = new UserServices();
     service.UpdateTeacher(model);
     return RedirectToAction("ManageTeachers", "DatabaseAction");
 }
 public ActionResult DeleteTeacher(TeacherModel model)
 {
     UserServices ServicesForUser = new UserServices();
     ServicesForUser.DeleteTeacher(model);
     return RedirectToAction("ManageTeachers");
 }
 public ActionResult EditTeacher(int IdNauczyciela)
 {
     UserServices service = new UserServices();
     TeacherModel model = new TeacherModel();
     model = service.GetTeacher(IdNauczyciela);
     return View(model);
 }
        public ActionResult InsertSolution(SolutionModel model,HttpPostedFileBase upload)
        {
            CourseServices cs = new CourseServices();
            UserServices us = new UserServices();
            HttpCookie loggedStudent = Request.Cookies["LoggedUser"];
            model.Student = us.GetStudent(loggedStudent.Values.Get("Login"));
            model.StudentId = model.Student.IdUcznia;
            model.FileName = upload.FileName;
            using (var reader = new System.IO.BinaryReader(upload.InputStream))
            {
                model.Solution = reader.ReadBytes(upload.ContentLength);
            }
            cs.NewSolution(model);

            return RedirectToAction("ManageCourses","Student");
        }
Exemplo n.º 30
0
 public CourseModel GetCourse(int CourseId)
 {
     var course = db.Kursy.Where(x => x.IdKursu == CourseId).FirstOrDefault();
     CourseModel model = new CourseModel();
     model.CourseId = course.IdKursu;
     model.ClassId = course.IdKlasy;
     model.Class = db.Klasy.Where(x => x.IdKlasy == course.IdKlasy).Select(p => p.Oddział).FirstOrDefault();
     model.CourseDescription = course.Opis;
     model.CourseTitle = course.Tytuł;
     model.SubjectId = course.IdPrzedmiotu;
     model.Subject = db.Przedmioty.Where(x => x.IdPrzedmiotu == course.IdPrzedmiotu).Select(p => p.NazwaPrzedmiotu).FirstOrDefault();
     model.TeacherId = course.IdProwadzącego;
     var tasks = db.Zadania.Where(x => x.IdKursu == CourseId).ToList();
     model.Tasks = new List<TaskModel>();
     foreach(var task in tasks)
     {
         model.Tasks.Add(new TaskModel
         {
             CourseId = task.IdKursu,
             CreationDate = (DateTime)task.DataWstawienia,
             DeadLineDate = (DateTime)task.DataOddania,
             Descriprion = task.Treść,
             TaskId = task.IdZadania
         });
     }
     UserServices us = new UserServices();
     model.Subjects = GetSubjects();
     model.Classes = us.GetClasses();
     return model;
 }
 public ActionResult EditStudent(StudentModel model)
 {
     UserServices ServicesForUser = new UserServices();
     ServicesForUser.UpdateStudent(model);
     return RedirectToAction("Index");
 }
 public ActionResult EditStudent(int IdUcznia)
 {
     UserServices ServicesForUser = new UserServices();
     StudentModel model = new StudentModel();
     model = ServicesForUser.GetStudent(IdUcznia);
     model.Oddziały = ServicesForUser.GetClasses();
     return View(model);
 }