Exemplo n.º 1
0
        //GetAllByKind
        public static List <Items1> GetAllVideos(int kindId, int pageNum)
        {
            const int    numVideoInPage = 10;
            List <Items> lst            = new List <Items>(ItemsDL.GetAllItems());

            return(ItemsConvertor.ConvertToListDto(lst.Where(i => i.ItemKind == kindId).Skip(numVideoInPage * pageNum).Take(numVideoInPage).ToList()));
        }
Exemplo n.º 2
0
        //Delete
        public static void DeleteItem(Items1 item)
        {
            Items newItem = ItemsConvertor.ConvertToDL(item);

            ItemsSubjectBL.DeleteItemsSubjectByItemId(newItem.ItemId);
            //TODO
            //WordsLocationsBL.DeleteWordsLocationsByItemId(newItem.ItemId);
            BookPagesBL.DeleteBookByItemId(newItem.ItemId);

            ItemsDL.DeleteItem(newItem);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        //Add
        public static void AddItem(Items1 item)
        {
            Items newItem = ItemsConvertor.ConvertToDL(item);

            try
            {
                ItemsDL.AddItem(newItem);
                if (newItem.EnableSearch)
                {
                    BL.BookPagesBL.AddBookByItem(newItem);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 5
0
        // GetAllBySubjectId
        public static List <Items1> GetAllBySubjectId(int subjectId)
        {
            List <Items> lst = new List <Items>(ItemsDL.GetAllItems());

            return(ItemsConvertor.ConvertToListDto(lst.Where(i => i.ItemsSubject != null && i.ItemsSubject?.Where(x => x.SubjectId == subjectId).Count() > 0).ToList()));
        }
Exemplo n.º 6
0
        //TODO
        public static List <Items1> GetAllByKind(int kindId)
        {
            List <Items> lst = new List <Items>(ItemsDL.GetAllItems());

            return(ItemsConvertor.ConvertToListDto(lst.Where(i => i.ItemKind == kindId).ToList()));
        }
Exemplo n.º 7
0
 //GetAll
 public static List <Items1> GetAllItems()
 {
     return(ItemsConvertor.ConvertToListDto(ItemsDL.GetAllItems()));
 }
Exemplo n.º 8
0
        //GetByName
        public static Items1 GetItemByName(string item)
        {
            List <Items> lst = new List <Items>(ItemsDL.GetAllItems());

            return(ItemsConvertor.ConvertToDto(lst.Where(i => i.ItemName.Equals(item)).FirstOrDefault()));
        }
Exemplo n.º 9
0
 //GetById
 public static Items1 GetItemById(int item)
 {
     return(ItemsConvertor.ConvertToDto(ItemsDL.GetItemById(item)));
 }
Exemplo n.º 10
0
        //Update
        public static void UpdateItem(Items1 item)
        {
            Items newItem = ItemsConvertor.ConvertToDL(item);

            ItemsDL.UpdateItem(newItem);
        }