public ActionResult TaskDelete(TaskModel task)
        {
            CourseServices cs = new CourseServices();

            cs.TaskDelete(task);
            return(RedirectToAction("ManageTasks", task.CourseId));
        }
Example #2
0
        public ActionResult Component(int id)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);
            var course         = courseServices.GetCourseById(id);

            ViewBag.Title = course.Name;
            ViewBag.Email = Session["email"];
            ViewBag.Id    = course.Id;

            if (course == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            IList <ComponentViewModel> components = new List <ComponentViewModel>();

            foreach (var component in course.Components)
            {
                components.Add(new ComponentViewModel(component));
            }
            return(View(components));
        }
Example #3
0
        public ActionResult AddCourse(string course_name, CourseStatus status)
        {
            var result = new ResultData <Course>()
            {
                Error = true, Status = HttpStatusCode.BadRequest
            };

            try
            {
                CourseServices.ValidateName(course_name);
                Course course = new Course(course_name, status);
                if (db.Curso.Where(q => q.Name.ToLower() == course_name.ToLower()).Any())
                {
                    throw new ArgumentException($"O nome {course.Name} já esta cadastrado");
                }

                db.Curso.Add(course);
                db.SaveChanges();
                result.Error  = false;
                result.Status = HttpStatusCode.OK;
                result.Data   = db.Curso.ToList();
                return(Ok(result));
            }
            catch (Exception e)
            {
                result.Message.Add(e.Message);
                return(BadRequest(result));
            }
            finally
            {
                db.Dispose();
            }
        }
Example #4
0
        public ActionResult StudentsEnrolled(int id, bool?error)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Email = Session["email"];

            if (error == true)
            {
                ModelState.AddModelError("prag_error", "Nemoguće unjeti više bodova od maksimalnog broj bodova po komponenti!");
            }

            var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);
            var course         = courseServices.GetCourseById(id);

            ViewBag.Title = course.Name;

            var             studentServices            = new StudentServices(_userRepository);
            var             scoreServices              = new ScoreServices(_scoreRepository, _courseRepository, _userRepository);
            IList <Student> enrolledStudents           = studentServices.GetStudentsByCourse(course);
            IList <StudentEnrollementViewModel> enroll = new List <StudentEnrollementViewModel>();

            foreach (Student s in enrolledStudents)
            {
                IList <Score> score = scoreServices.GetScorebyStudentAndCourse(s.Id, course.Id);
                enroll.Add(new StudentEnrollementViewModel(score));
            }
            return(View(enroll));
        }
Example #5
0
        public ActionResult Index()
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Email = Session["email"];
            ViewBag.Title = "Predmeti";

            int userId = (int)Session["userId"];
            List <LecturerCourseViewModel> courseList = new List <LecturerCourseViewModel>();

            var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);
            var courses        = courseServices.GetCoursesByLecturerId(userId);

            if (courses != null)
            {
                foreach (var course in courses)
                {
                    courseList.Add(new LecturerCourseViewModel(course));
                }
            }
            return(View(courseList));
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Course id</param>
        /// <returns></returns>
        public ActionResult ScoreInfo(int id)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Email = Session["email"];
            ViewBag.Title = "Bodovi";
            var studentId      = (int)Session["userId"];
            var scoreServcies  = new ScoreServices(_scoreRepository, _courseRepository, _userRepository);
            var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);

            var course = courseServices.GetCourseById(id);

            var scores          = scoreServcies.GetScorebyStudentAndCourse(studentId, id);
            var scoresViewModel = new List <ScoreViewModel>();

            foreach (var score in scores)
            {
                scoresViewModel.Add(new ScoreViewModel(score));
            }
            scoresViewModel.Sort((m1, m2) => m1.ComponentName.CompareTo(m2.ComponentName));



            var scoredCourse = new ScoredCourseViewModel()
            {
                Name      = course.Name,
                scoreList = scoresViewModel
            };

            return(View(scoredCourse));
        }
        public ActionResult NoteEdit(SolutionModel model)
        {
            CourseServices service = new CourseServices();

            service.EditNote(model);
            return(RedirectToAction("TaskSolutions", new { TaskId = model.TaskId }));
        }
        public ActionResult TaskList(int CourseId)
        {
            CourseServices   cs    = new CourseServices();
            List <TaskModel> tasks = cs.GetTasks(CourseId);

            return(View(tasks));
        }
Example #9
0
        // GET: u_course_portal/Details/5
        public ActionResult Details(int id)
        {
            CourseServices         courseServices  = new CourseServices();
            List <u_course_portal> CoursesRespList = courseServices.GetCoursesByPortalID(id);

            return(PartialView("courseview", CoursesRespList));
        }
        public ActionResult CourseEdit(CourseModel model)
        {
            CourseServices services = new CourseServices();

            services.CourseEdit(model);
            return(RedirectToAction("Index", "Teacher"));
        }
        public ActionResult CreateNewTask(int CourseId)
        {
            CourseServices service = new CourseServices();
            TaskModel      model   = new TaskModel();

            return(View(model));
        }
        public ActionResult CreateNewTask(TaskModel model)
        {
            CourseServices service = new CourseServices();

            service.NewTask(model);
            return(RedirectToAction("ManageTasks"));
        }
        public ActionResult TaskEdit(TaskModel model)
        {
            CourseServices service = new CourseServices();

            service.EditTask(model);
            return(RedirectToAction("ManageTasks", model.CourseId));
        }
Example #14
0
        public ScoredCourse GetScoreData(int studentId, int courseId)
        {
            var scoreServcies  = new ScoreServices(_scrRep, _corRep, _usrRep);
            var courseServices = new CourseServices(_corRep, _usrRep, _comRep);

            var course = courseServices.GetCourseById(courseId);

            var scores          = scoreServcies.GetScorebyStudentAndCourse(studentId, courseId);
            var scoresViewModel = new List <SimpleScore>();

            foreach (var score in scores)
            {
                scoresViewModel.Add(new SimpleScore(score));
            }
            scoresViewModel.Sort((m1, m2) => m1.ComponentName.CompareTo(m2.ComponentName));



            var scoredCourse = new ScoredCourse()
            {
                Name      = course.Name,
                ScoreList = scoresViewModel
            };

            return(scoredCourse);
        }
        public ActionResult TaskDelete(int TaskId)
        {
            CourseServices cs    = new CourseServices();
            TaskModel      model = new TaskModel();

            model = cs.GetTask(TaskId);
            return(View(model));
        }
        public ActionResult TaskEdit(int TaskId)
        {
            CourseServices service = new CourseServices();
            TaskModel      model   = new TaskModel();

            model = service.GetTask(TaskId);
            return(View(model));
        }
        public ActionResult CourseDelete(CourseModel model)
        {
            CourseServices services = new CourseServices();

            model.Tasks = services.GetTasks(model.CourseId);
            services.CourseDelete(model);
            return(RedirectToAction("Index", "Teacher"));
        }
        public ActionResult StudentSolution(int SolutionId)
        {
            SolutionModel  model   = new SolutionModel();
            CourseServices service = new CourseServices();

            model = service.GetSolution(SolutionId);
            return(View(model));
        }
        public ActionResult CourseDelete(int CourseId)
        {
            CourseServices services = new CourseServices();
            CourseModel    model    = new CourseModel();

            model = services.GetCourse(CourseId);
            return(View(model));
        }
        public ActionResult NoteEdit(int SolutionId)
        {
            SolutionModel  solution = new SolutionModel();
            CourseServices service  = new CourseServices();

            solution = service.GetSolution(SolutionId);
            return(View(solution));
        }
        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 CreateCourse()
        {
            CourseModel    model             = new CourseModel();
            CourseServices ServiceForCourses = new CourseServices();
            UserServices   ServicesForUsers  = new UserServices();

            model.Subjects = ServiceForCourses.GetSubjects();
            model.Classes  = ServicesForUsers.GetClasses();
            return(View(model));
        }
Example #23
0
        public ActionResult CreateComponent(ComponentViewModel comp)
        {
            var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);
            var course         = courseServices.GetCourseById(comp.Id);

            var componentServices = new ComponentServices(_componentRepository, _courseRepository);
            var component         = componentServices.CreateComponent(comp.Name, comp.CourseId, comp.MinimumPointsToPass, comp.MaximumPoints);

            return(RedirectToAction("Component", "Lecturer", new { id = comp.CourseId }));
        }
        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 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 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 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"));
        }
Example #29
0
        public static void Main()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways <StudentSystemDbContext>());

            var data = new StudentsSystemData();

            var courses = data.Courses.All();

            var students = data.Students.All();

            var courseNames = new string[] { "js apps", "js ui and dom", "csharp oop", "databases" };

            foreach (var name in courseNames)
            {
                data.Courses.Add(new Course()
                {
                    Description = "kopon",
                    Name        = name
                });
            }

            data.SaveChanges();

            foreach (var course in courses)
            {
                Console.WriteLine(course.Name);
            }

            var courseServices = new CourseServices(data.Courses);

            Console.WriteLine(string.Join(", ", courseServices.GetJavascriptCourses().Select(c => c.Name)));

            var student = new Student()
            {
                FirstName             = "pencho",
                LastName              = "genchov",
                Level                 = 99,
                AdditionalInformation = new StudentInfo()
                {
                    Address = "ul. gorno nanadolnishte", Email = "*****@*****.**"
                }
            };

            data.Students.Add(student);
            courseServices.AddStudentToCourse(student, "js apps");

            data.SaveChanges();

            var pencho = data.Students.All().FirstOrDefault(s => s.FirstName == "pencho");

            Console.WriteLine("pencho is in the " + pencho.Courses.FirstOrDefault().Name + " course");
        }
Example #30
0
        public CourseFormTests()
        {
            var nhs = new NHibernateService2();

            _userRepository      = new UserRepository(nhs);
            _courseRepository    = new CourseRepository(nhs);
            _componentRepository = new ComponentRepository(nhs);
            _scoreRepository     = new ScoreRepository(nhs);

            _userServices   = new UserServices(_userRepository);
            _courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);
            _scoreServices  = new ScoreServices(_scoreRepository, _courseRepository, _userRepository);
        }
        public static void Main()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways<StudentSystemDbContext>());

            var data = new StudentsSystemData();

            var courses = data.Courses.All();

            var students = data.Students.All();

            var courseNames = new string[] { "js apps", "js ui and dom", "csharp oop", "databases" };

            foreach (var name in courseNames)
            {
                data.Courses.Add(new Course()
                {
                    Description = "kopon",
                    Name = name
                });
            }

            data.SaveChanges();

            foreach (var course in courses)
            {
                Console.WriteLine(course.Name);
            }

            var courseServices = new CourseServices(data.Courses);

            Console.WriteLine(string.Join(", ", courseServices.GetJavascriptCourses().Select(c => c.Name)));

            var student = new Student()
            {
                FirstName = "pencho",
                LastName = "genchov",
                Level = 99,
                AdditionalInformation = new StudentInfo() { Address = "ul. gorno nanadolnishte", Email = "*****@*****.**" }
            };

            data.Students.Add(student);
            courseServices.AddStudentToCourse(student, "js apps");

            data.SaveChanges();

            var pencho = data.Students.All().FirstOrDefault(s => s.FirstName == "pencho");

            Console.WriteLine("pencho is in the " + pencho.Courses.FirstOrDefault().Name + " course");
        }