public ActionResult CourseDelete(CourseModel model)
 {
     CourseServices services = new CourseServices();
     model.Tasks = services.GetTasks(model.CourseId);
     services.CourseDelete(model);
     return RedirectToAction("Index", "Teacher");
 }
 public ActionResult CourseEdit(int CourseId)
 {
     CourseServices services = new CourseServices();
     CourseModel model = new CourseModel();
     model = services.GetCourse(CourseId);
     return View(model);
 }
 public FileContentResult Download(int SolutionId)
 {
     CourseServices cs = new CourseServices();
     SolutionModel model = new SolutionModel();
     model = cs.GetSolution(SolutionId);
     FileServices fs = new FileServices();
     string ContentType = fs.GetContentType(model.Extension);
     return File(model.Solution,ContentType,model.FileName);
 }
 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 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 TaskDelete(TaskModel task)
 {
     CourseServices cs = new CourseServices();
     cs.TaskDelete(task);
     return RedirectToAction("ManageTasks", task.CourseId);
 }
 public ActionResult CreateNewTask(TaskModel model)
 {
     CourseServices service = new CourseServices();
     service.NewTask(model);
     return RedirectToAction("ManageTasks");
 }
 public ActionResult CreateNewTask(int CourseId)
 {
     CourseServices service = new CourseServices();
     TaskModel model = new TaskModel();
     return View(model);
 }
 public ActionResult CourseEdit(CourseModel model)
 {
     CourseServices services = new CourseServices();
     services.CourseEdit(model);
     return RedirectToAction("Index", "Teacher");
 }
 public ActionResult ManageCourses()
 {
     List<CourseModel> courses = new List<CourseModel>();
     CourseServices CourseServ = new CourseServices();
     UserServices UserServ = new UserServices();
     HttpCookie loggedTeacher = Request.Cookies["LoggedUser"];
     TeacherModel teacher = UserServ.GetTeacher(loggedTeacher.Values.Get("Login"));
     courses = CourseServ.GetCourses(teacher.IdNauczyciela);
     return View(courses);
 }
 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);
 }
 public ActionResult TaskSolutions(int TaskId)
 {
     TaskModel task = new TaskModel();
     CourseServices service = new CourseServices();
     task = service.GetTask(TaskId);
     List<SolutionModel> solutions = new List<SolutionModel>();
     solutions = service.GetSolutions(TaskId);
     return View(solutions);
 }
 public ActionResult TaskEdit(TaskModel model)
 {
     CourseServices service = new CourseServices();
     service.EditTask(model);
     return RedirectToAction("ManageTasks", model.CourseId);
 }
 public ActionResult TaskDelete(int TaskId)
 {
     CourseServices cs = new CourseServices();
     TaskModel model = new TaskModel();
     model = cs.GetTask(TaskId);
     return View(model);
 }
 public ActionResult ManageTasks(int CourseId)
 {
     CourseServices service = new CourseServices();
     CourseModel model = new CourseModel();
     model = service.GetCourse(CourseId);
     model.Tasks = service.GetTasks(CourseId);
     return View(model.Tasks);
 }
 public ActionResult StudentSolution(int SolutionId)
 {
     SolutionModel model = new SolutionModel();
     CourseServices service = new CourseServices();
     model = service.GetSolution(SolutionId);
     return View(model);
 }
 public ActionResult NoteEdit(SolutionModel model)
 {
     CourseServices service = new CourseServices();
     service.EditNote(model);
     return RedirectToAction("TaskSolutions", new { TaskId = model.TaskId });
 }
        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 TaskList(int CourseId)
 {
     CourseServices cs = new CourseServices();
     List<TaskModel> tasks = cs.GetTasks(CourseId);
     return View(tasks);
 }
 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 NoteEdit(int SolutionId)
 {
     SolutionModel solution = new SolutionModel();
     CourseServices service = new CourseServices();
     solution = service.GetSolution(SolutionId);
     return View(solution);
 }
 public ActionResult TaskEdit(int TaskId)
 {
     CourseServices service = new CourseServices();
     TaskModel model = new TaskModel();
     model = service.GetTask(TaskId);
     return View(model);
 }