//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())); }
//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); }
//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); } }
//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); } }
// 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())); }
//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())); }
//GetAll public static List <Items1> GetAllItems() { return(ItemsConvertor.ConvertToListDto(ItemsDL.GetAllItems())); }
//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())); }
//GetById public static Items1 GetItemById(int item) { return(ItemsConvertor.ConvertToDto(ItemsDL.GetItemById(item))); }
//Update public static void UpdateItem(Items1 item) { Items newItem = ItemsConvertor.ConvertToDL(item); ItemsDL.UpdateItem(newItem); }