コード例 #1
0
        public bool AddTypeInCourseLevel(int courseId, int levelId, int typeId)
        {
            var course = db.Kurset.FirstOrDefault(x => x.KursId == courseId);
            var level  = db.Nivelet.FirstOrDefault(x => x.Id == levelId);
            var type   = db.Tipet.FirstOrDefault(x => x.Id == typeId);

            //ne nje seksion nuk mund te shtohen kurse,nivele apo tipe qe nuk ekzistojne
            if (level == null || course == null || type == null)
            {
                return(false);
            }
            var sectionToUpdate = db.KursNivelTip.Where(x => x.KursiId == courseId && x.NiveliId == levelId && x.TipiId == null).FirstOrDefault();

            //ne rast se ka nje seksion me kurs dhe nivel perkates dhe tipId=null
            //(rasti kur niveli i nje kursi nuk ka asnje tip)
            //modifikohet seksioni ekzistues ne te kundert behet shtimi i nje seksioni te ri
            if (sectionToUpdate != null)
            {
                sectionToUpdate.TipiId = typeId;
            }
            else
            {
                KursNivelTip newSection = new KursNivelTip()
                {
                    KursiId  = courseId,
                    NiveliId = levelId,
                    TipiId   = typeId
                };
                db.KursNivelTip.Add(newSection);
            }
            db.SaveChanges();
            return(true);
        }
コード例 #2
0
        public ActionResult AddLevelInCourse(Nivel selectedLevel, int courseId)
        {
            string uid = User.Identity.GetUserId();

            if (!courseService.CanUserModifyCourseLevelsAndTypes(uid, courseId))
            {
                this.AddNotification("Ju nuk mund te shtoni nivele ne kursin me id:" + courseId, NotificationType.ERROR);
                return(RedirectToAction("CourseLevels", "Course", new { @id = courseId }));
            }
            if (selectedLevel.Id == 0)
            {
                this.AddNotification("Opsioni qe ju zgjodhet nuk eshte i vlefshem.", NotificationType.ERROR);
                return(RedirectToAction("AddLevelInCourse", "Level", new { @id = courseId }));
            }
            var levelToAdd = levelService.GetLevelById(selectedLevel.Id);

            if (levelToAdd == null)
            {
                return(new HttpNotFoundResult());
            }
            KursNivelTip newSection = new KursNivelTip()
            {
                KursiId  = courseId,
                NiveliId = selectedLevel.Id
            };

            sectionService.CreateSection(newSection);
            this.AddNotification(levelToAdd.Emri + " u shtua me sukses ne kursin " + TempData["Course"], NotificationType.SUCCESS);
            return(RedirectToAction("CourseLevels", "Course", new { @id = courseId }));
        }
コード例 #3
0
        public ActionResult MaterialsOfSection(int id)
        {
            KursNivelTip currentSection = sectionService.GetSectionById(id);

            //nuk mund te aksesohen materialet e nje seksioni qe nuk ekziston ose qe nuk ka nje tip
            if (currentSection == null || currentSection.TipiId == null)
            {
                return(new HttpNotFoundResult());
            }
            List <Material> materials = mService.GetMaterialsOf(id);

            ViewBag.Kursi        = currentSection.Kursi.Emri;
            ViewBag.KursId       = currentSection.Kursi.KursId;
            ViewBag.Niveli       = currentSection.Niveli.Emri;
            ViewBag.NivelId      = currentSection.Niveli.Id;
            ViewBag.Tipi         = currentSection.Tipi.Tipi;
            ViewBag.SeksionId    = currentSection.Id;
            ViewBag.InstruktorId = currentSection.Kursi.InstruktoriId;
            return(View(materials));
        }
コード例 #4
0
 public void CreateSection(KursNivelTip newSection)
 {
     sectionRepository.CreateSection(newSection);
 }
コード例 #5
0
 public void CreateSection(KursNivelTip newSection)
 {
     db.KursNivelTip.Add(newSection);
     db.SaveChanges();
 }