示例#1
0
        public void DeleteFilesForGivenId(Guid id)
        {
            var lecture = _repository.GetLectureById(id);

            var searchedPath = Path.Combine(_env.WebRootPath, "Lectures/" + id);

            if (Directory.Exists(searchedPath))
            {
                Directory.Delete(searchedPath, true);
            }

            _repository.DeleteLecture(lecture);
        }
示例#2
0
        public async Task <IActionResult> EditLecture(int id)
        {
            var objLecture = await _LectureRepository.GetLectureById(id);

            EditLectureViewModel model = new EditLectureViewModel
            {
                //Id = objLecture.Lecture_Id,
                Id             = objLecture.Id,
                Lecture_Name   = objLecture.Lecture_Name,
                Lecture_Detail = objLecture.Lecture_Detail,
                //ExistingFilePath = objLecture.Lecture_File,
                ExistingFilePath = objLecture.ExistingFilePath,
                LecturePost_Date = objLecture.LecturePost_Date,
                Class_Id         = objLecture.Class_Id,
                Section_Id       = objLecture.Section_Id,
                Subject_Id       = objLecture.Subject_Id
            };

            List <SelectListItem> classList = new List <SelectListItem>();

            classList.Insert(0, new SelectListItem()
            {
                Value = "-1", Text = "--Select--"
            });
            var objClassSecSub = _LectureRepository.GetAllClassSectionByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 1).ToList();

            foreach (var lstclass in objClassSecSub)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstclass.Class_Name,
                    Value = lstclass.Class_Id.ToString(),
                };

                classList.Add(selectListItem);
            }
            ViewBag.ClassList = classList;


            List <SelectListItem> sectionList = new List <SelectListItem>();

            sectionList.Insert(0, new SelectListItem()
            {
                Value = "-1", Text = "--Select--"
            });
            foreach (var lstSection in objClassSecSub)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstSection.Section_Name,
                    Value = lstSection.Section_Id.ToString(),
                };

                sectionList.Add(selectListItem);
            }
            ViewBag.SectionList = sectionList;

            List <SelectListItem> subjectList = new List <SelectListItem>();

            subjectList.Insert(0, new SelectListItem()
            {
                Value = "-1", Text = "--Select--"
            });
            var objSubject = _LectureRepository.GetAllSubjectByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 1).ToList();

            foreach (var lstSubject in objSubject)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstSubject.Subject_Name,
                    Value = lstSubject.Subject_Id.ToString(),
                };

                subjectList.Add(selectListItem);
            }
            ViewBag.SubjectList = subjectList;

            return(View(model));
        }