Esempio n. 1
0
        //GetItemsBySubjectId
        public static ItemsForSubject GetItemsBySubjectId(int subjectId)
        {
            try
            {
                List <Items>    lst             = new List <Items>(ItemsDL.GetAllItems().Where(i => i.ItemsSubject.FirstOrDefault(s => s.SubjectId == subjectId) != null));
                ItemsForSubject itemsForSubject = new ItemsForSubject();
                var             subjectName     = SubjectsDL.GeSubjectById(subjectId).Subject;
                var             folderpath      = $"{HttpContext.Current.Server.MapPath("~/Files/")}{EnumItemsKinds.Bookmarks}";
                if (Directory.Exists(folderpath) && File.Exists($"{folderpath}/{subjectName}"))
                {
                    itemsForSubject.bookmarksPath = $"{folderpath}/{subjectName}";
                }

                folderpath = $"{HttpContext.Current.Server.MapPath("~/Files/")}{EnumItemsKinds.Book}";
                if (Directory.Exists(folderpath) && File.Exists($"{ folderpath}/{subjectName}"))
                {
                    itemsForSubject.bookPath = $"{folderpath}/{subjectName}";
                }

                folderpath = $"{HttpContext.Current.Server.MapPath("~/Files/")}Image";
                if (Directory.Exists(folderpath) && File.Exists($"{ folderpath}/{subjectName}"))
                {
                    itemsForSubject.bookPath = $"{folderpath}/{subjectName}";
                }

                folderpath = $"{HttpContext.Current.Server.MapPath("~/Files/")}{EnumItemsKinds.Lesson}";
                if (Directory.Exists(folderpath) && File.Exists($"{ folderpath}/{subjectName}"))
                {
                    itemsForSubject.bookPath = $"{folderpath}/{subjectName}";
                }

                folderpath = $"{HttpContext.Current.Server.MapPath("~/Files/")}{EnumItemsKinds.Video}";
                if (Directory.Exists(folderpath) && File.Exists($"{ folderpath}/{subjectName}"))
                {
                    itemsForSubject.bookPath = $"{folderpath}/{subjectName}";
                }

                folderpath = $"{HttpContext.Current.Server.MapPath("~/Files/")}{EnumItemsKinds.LessonSummary}";
                if (Directory.Exists(folderpath) && File.Exists($"{ folderpath}/{subjectName}"))
                {
                    itemsForSubject.lessonSummary = FilesDL.GetTextFromFile($"{folderpath}/{subjectName}");
                }
                return(itemsForSubject);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 2
0
 //GetById
 public static Subjects1 GetSubjectById(int subjectId)
 {
     return(SubjectsConvertor.ConvertToDto(SubjectsDL.GeSubjectById(subjectId)));
 }