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); }
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))); }
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); }