public ActionResult AddNewStudent()
 {
     StudentModel model = new StudentModel();
     UserServices ServiceForUser = new UserServices();
     model.Oddziały = ServiceForUser.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 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 ActionResult DeleteStudent(StudentModel model)
 {
     UserServices ServicesForUser = new UserServices();
     ServicesForUser.DeleteStudent(model);
     return RedirectToAction("ManageStudents");
 }
 public ActionResult DeleteStudent(int IdUcznia)
 {
     UserServices ServicesForUser = new UserServices();
     StudentModel model = new StudentModel();
     model = ServicesForUser.GetStudent(IdUcznia);
         return View(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);
 }
 public SolutionModel GetSolution(int TaskId,StudentModel model)
 {
     SolutionModel solution = new SolutionModel();
     var query = db.Rozwiązania.Where(x => x.IdZadania == TaskId && x.IdUcznia == model.IdUcznia).FirstOrDefault();
     solution.Student = model;
     solution.StudentId = model.IdUcznia;
     solution.Note = query.Ocena;
     solution.Notes = GetPossibleNotes();
     solution.SolutionId = query.IdRozwiązania;
     solution.Solution = query.TreśćRozwiązania;
     solution.FileName = query.NazwaPliku;
     solution.Extension = query.Rozszerzenie;
     solution.Comment = query.Komentarz;
     return solution;
 }
 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);
 }
Пример #11
0
 //Aktualizacja rekordu o studencie na podstawie modelu
 public void UpdateStudent(StudentModel model)
 {
     var query = db.Uczniowie.Where(x => x.IdUcznia == model.IdUcznia).FirstOrDefault();
     query.IdUcznia = model.IdUcznia;
     query.IdKlasy = model.IdKlasy;
     query.Hasło = model.Password;
     query.Login = model.Login;
     query.Imię = model.Name;
     query.Nazwisko = model.Surname;
     db.SaveChanges();
 }
Пример #12
0
 //Kasowanie rekordu studenta na podstawie modelu
 public void DeleteStudent(StudentModel model)
 {
     var studentRef = db.Rozwiązania.Where(x => x.IdUcznia == model.IdUcznia).ToList();
     db.Rozwiązania.RemoveRange(studentRef);
     var item = db.Uczniowie.Where(x => x.IdUcznia == model.IdUcznia).FirstOrDefault();
     db.Uczniowie.Remove(item);
     db.SaveChanges();
 }
Пример #13
0
 //Pobieranie rekordu o studencie po informacjach
 public StudentModel GetStudent(string Login)
 {
     
     var item = db.Uczniowie.Where(x => x.Login == Login).FirstOrDefault();
     StudentModel model = new StudentModel();
     model.IdKlasy = item.IdKlasy;
     model.IdUcznia = item.IdUcznia;
     model.Klasa = db.Klasy.FirstOrDefault(x => x.IdKlasy == item.IdKlasy).Oddział;
     model.Login = item.Login;
     model.Password = item.Hasło;
     model.Name = item.Imię;
     model.Surname = item.Nazwisko;
     return model;
 }
Пример #14
0
        //Pobieranie rekordu o studencie po Identyfikatorze
        public StudentModel GetStudent(int IdUcznia)
        {

            var uczen = db.Uczniowie.Where(x => x.IdUcznia == IdUcznia).FirstOrDefault();

            StudentModel model = new StudentModel();
            model.IdKlasy = uczen.IdKlasy;
            model.IdUcznia = uczen.IdUcznia;
            model.Klasa = db.Klasy.FirstOrDefault(x => x.IdKlasy == uczen.IdKlasy).Oddział;
            model.Login = uczen.Login;
            model.Password = uczen.Hasło;
            model.Name = uczen.Imię;
            model.Surname = uczen.Nazwisko;
            return model;
        }
Пример #15
0
 //Tworzenie nowego wpisu o uczniu w bazie danych 
 public void CreateNewStudent(StudentModel model)
 {
     db.Uczniowie.Add(new Uczniowie
     {
         IdUcznia = db.Uczniowie.Max(x =>x.IdUcznia)+1,
         Login = model.Login,
         Hasło = model.Password,
         Imię = model.Name,
         Nazwisko = model.Surname,
         IdKlasy = model.IdKlasy
     });
     db.SaveChanges();
 }