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 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 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 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 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 EditStudent(int IdUcznia)
 {
     UserServices ServicesForUser = new UserServices();
     StudentModel model = new StudentModel();
     model = ServicesForUser.GetStudent(IdUcznia);
     model.Oddziały = ServicesForUser.GetClasses();
     return View(model);
 }
 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 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 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");
        }
 public ActionResult StudentSolution(int TaskId)
 {
     CourseServices cs = new CourseServices();
     UserServices us = new UserServices();
     HttpCookie cookie = Request.Cookies.Get("LoggedUser");
     cookie.Values.Get("Name");
     cookie.Values.Get("Surname");
     cookie.Values.Get("Login");
     StudentModel student = new StudentModel();
     student = us.GetStudent(cookie.Values.Get("Login"));
     SolutionModel solution = new SolutionModel();
     solution = cs.GetSolution(TaskId, student);
     return View(solution);
 }
 public ActionResult ManageCourses()
 {
     CourseServices cs = new CourseServices();
     UserServices us = new UserServices();
     List<CourseModel> courses = new List<CourseModel>();
     HttpCookie loggedStudent = Request.Cookies["LoggedUser"];
     StudentModel student = us.GetStudent(loggedStudent.Values.Get("Login"));
     courses = cs.GetCourses().Where(x => x.ClassId == student.IdKlasy).ToList();
     return View(courses);
 }