public int SaveChanges(ChapterForm form) { var tChapter = Table <Chapter>(); var chapter = tChapter.GetOrAdd(w => w.ID == form.ID || (w.ID == 0 && w.NovelID == form.NovelID && w.Volume == form.Volume && w.Number == form.Number)); MapProperty(form, chapter, form.InlineEditProperty); UpdateAuditFields(chapter, form.ByUserID); // save SaveChanges(); // save chapter content if (!string.IsNullOrWhiteSpace(form.Content)) { var tContent = Table <Content>(); var segments = form.Content.SegmentChapterContent(); foreach (var segment in segments) { var content = tContent.GetOrAdd(w => w.ChapterID == chapter.ID && w.RawHash == segment.Key); if (content.ID == 0) // only add when the paragraph is new (does not exist) { UpdateAuditFields(content, form.ByUserID); content.ChapterID = chapter.ID; content.RawHash = segment.Key; content.Final = segment.Value; // save SaveChanges(); } } } return(chapter.ID); }
public int AddChapter(ChapterForm chapterForm) { using (var uow = UnitOfWorkFactory.Create <NovelContext>()) { var service = new ChapterService(uow); return(service.SaveChanges(chapterForm)); } }
public ActionResult Add(ChapterForm form) { return(View(form)); }
public JsonResult Form(ChapterForm chapter) { return(SaveChanges(chapter, Facade <NovelFacade>().AddChapter)); }