Esempio n. 1
0
        public Chapter UpdateChapter(ChapterCreatingInputModel model)
        {
            var chapter = appDbContext.Chapters.Include(c => c.FanFiction).Single(c => c.FanFiction.Id == model.FanficId && c.Number == model.Number);

            chapter.Name    = model.Name;
            chapter.Image   = model.Image;
            chapter.Content = model.Content;
            appDbContext.SaveChanges();
            return(chapter);
        }
Esempio n. 2
0
 public IActionResult CreateOrEditChapter(ChapterCreatingInputModel model, string createFanfic, string goToNext)
 {
     if (model.IsUpdating)
     {
         fanficService.UpdateChapter(model);
     }
     else
     {
         fanficService.CreateChapter(model);
     }
     if (goToNext == null && createFanfic != null)
     {
         return(Redirect("/Home/Index"));
     }
     return(Redirect("/Fanfic/CreateOrEditChapter/?fanficId=" + model.FanficId + "&number=" + (model.Number + 1)));
 }
Esempio n. 3
0
        public Chapter CreateChapter(ChapterCreatingInputModel model)
        {
            var fanfic  = appDbContext.FanFictions.Find(model.FanficId);
            var chapter = new Chapter()
            {
                Name       = model.Name,
                Content    = model.Content,
                Image      = model.Image,
                FanFiction = fanfic,
                Number     = model.Number
            };

            appDbContext.Chapters.Add(chapter);
            appDbContext.SaveChanges();
            return(chapter);
        }