Ejemplo n.º 1
0
        public ActionResult StudentsEnrolled(IEnumerable <StudentEnrollementViewModel> list)
        {
            var scoreServices     = new ScoreServices(_scoreRepository, _courseRepository, _userRepository);
            var componentServices = new ComponentServices(_componentRepository, _courseRepository);
            var userServices      = new UserServices(_userRepository);

            foreach (var s in list)
            {
                foreach (var scor in s.scores)
                {
                    Score ss = new Score()
                    {
                        Id        = scor.Id,
                        Value     = scor.Value,
                        Component = componentServices.GetById(scor.Component.Id),
                        Student   = (Student)userServices.GetUserById(scor.Student.Id)
                    };
                    if (ss.Value > ss.Component.MaximumPoints)
                    {
                        return(RedirectToAction("StudentsEnrolled", "Lecturer", new { id = ss.Component.Course.Id, error = true }));
                    }
                    else
                    {
                        scoreServices.SaveScore(ss);
                    }
                }
            }
            return(RedirectToAction("Index", "Lecturer"));
        }
Ejemplo n.º 2
0
        public ActionResult EditComponent(int id)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var componentServices = new ComponentServices(_componentRepository, _courseRepository);
            var component         = componentServices.GetById(id);

            ViewBag.Title = component.Name + " " + component.Course.Name;
            ViewBag.Email = Session["email"];

            return(View(new ComponentViewModel(component)));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteComponent(int id, bool?error)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (error == true)
            {
                ModelState.AddModelError("error", "Ne možete pobrisati komponentu koja ima upisane bodove studentima!");
            }
            var componentServices = new ComponentServices(_componentRepository, _courseRepository);
            var component         = componentServices.GetById(id);

            ViewBag.Title = component.Name + " " + component.Course.Name;
            ViewBag.Email = Session["email"];

            return(View(new ComponentViewModel(component)));
        }