Exemple #1
0
        public ActionResult AddTypeInCourseLevel(Tip selectedtype, int courseId, int levelId)
        {
            string uid = User.Identity.GetUserId();

            if (!courseService.CanUserModifyCourseLevelsAndTypes(uid, courseId))
            {
                this.AddNotification("Ju nuk mund te shtoni tipe ne kursin me id:" + courseId, NotificationType.ERROR);
                return(RedirectToAction("CourseLevelTypes", "Course", new { @courseId = courseId, @levelId = levelId }));
            }
            if (selectedtype.Id == 0)
            {
                this.AddNotification("Opsioni qe ju zgjodhet nuk eshte i vlefshem.", NotificationType.ERROR);
                return(RedirectToAction("AddTypeInCourseLevel", new { @courseId = courseId, @levelId = levelId }));
            }
            bool wasAdded = sectionService.AddTypeInCourseLevel(courseId, levelId, selectedtype.Id);
            var  type     = typeService.GetTypeById(selectedtype.Id);
            var  level    = levelService.GetLevelById(levelId);

            if (wasAdded)
            {
                this.AddNotification("Tipi " + type.Tipi + " u shtua ne ne nivelin " + level.Emri, NotificationType.SUCCESS);
            }
            else
            {
                this.AddNotification("Tipi " + type.Tipi + " nuk u shtua ne ne nivelin " + level.Emri, NotificationType.ERROR);
            }
            return(RedirectToAction("CourseLevelTypes", "Course", new { @courseId = courseId, @levelId = levelId }));
        }