public PageEditModelToPageMapper( IDocumentSession session, SlugMaker slugMaker) { this.session = session; this.slugMaker = slugMaker; }
private static void SetSlug(Entry entry) { if (string.IsNullOrEmpty(entry.Slug)) { var slugMaker = new SlugMaker(); entry.Slug = slugMaker.CreateSlug(entry.Title); } }
public ActionResult Save(PageEditModel editModel) { if(!this.ModelState.IsValid) { return this.Json(new { error = true }); } var slugMaker = new SlugMaker(); var mapper = new PageEditModelToPageMapper(this.session, slugMaker); var page = mapper.Map(editModel); this.session.Store(page); this.session.SaveChanges(); return this.Json(page); }