Example #1
0
 public void AddNovel(tNovel novel)
 {
     using (var db = new NovelDbContext())
     {
         db.tNovels.Add(novel);
         db.SaveChanges();
     }
 }
Example #2
0
 public void Update(int id, NovelViewModel novel)
 {
     tNovel      = novelRepository.Get(m => m.NovelId == id);
     tNovel.Name = novel.Name;
     tNovel.Type = novel.Type;
     CheckAuthor(novel.Author);
     CheckCategory(novel.Category);
     novelRepository.Update(tNovel);
 }
Example #3
0
        public void Delete(int id)
        {
            tNovel novel = novelRepository.Get(m => m.NovelId == id);

            if (novel.Type.Replace(" ", "") == "日輕")
            {
                List <tNovelTextJ> chapterList = textJRepository.GetSome(m => m.NovelId == id).ToList();
                foreach (var item in chapterList)
                {
                    DeleteChapter(item.NovelTextId, novel.Type);
                }
            }
            else
            {
                List <tNovelTextC> chapterList = textCRepository.GetSome(m => m.NovelId == id).ToList();
                foreach (var item in chapterList)
                {
                    DeleteChapter(item.NovelTextId, novel.Type);
                }
            }
            novelRepository.Delete(novel);
        }