public Wiki AddWikiPage(string title, string body, User User, long CommunoityId = 0) { Wiki page = Wiki.FindFirst(x => x.Title.ToLower() == title.ToLower() && !x.Deleted); if (page != null) { throw new Exception("Wiki page with same name already exist."); } else { page = new Wiki(title, body); page.Save(User); } return(page); }
public Wiki GetWikiPageById(int id, bool Auth, long CommunityId = 0) { Wiki page = Wiki.FindFirst(x => x.Id == id && !x.Deleted && x.CommunityId == CommunityId); if (page == null) { throw new Exception(string.Format("No Wiki page with id: {0} could be found.", id)); } if (page.AuthRequired && Auth) { throw new Exception(string.Format("You need to login to view this page.")); } return(page); }
public Wiki SaveWikiPage(long Id, string Title, string Body) { Wiki wiki = Wiki.FindFirst(x => x.Id == Id); if (wiki != null) { wiki.Title = Title; wiki.Body = Body; } if (d.SaveWiki(wiki, sender.User) != null) { return(wiki); } else { throw new Exception("Unable to save wiki page."); } }
public Wiki SaveWiki(Wiki page, User User) { if (page == null) { throw new Exception("page cannot be null"); } if (User == null) { throw new Exception("User cannot be null"); } if (Wiki.FindFirst(x => x.Id == page.Id) == null) { throw new Exception("Wiki Page does not exist."); } page.Save(User); return(page); }
public Wiki GetWikiPageByTitle(string title, bool Auth, User User, long CommunityId = 0) { Wiki page = Wiki.FindFirst(x => x.Title.ToLower() == title.ToLower() && !x.Deleted && x.CommunityId == CommunityId); if (page == null) { if (!Auth) { throw new Exception(string.Format(string.Format("Page not found, login to automatically generate a page for: {0}", title))); } else { page = new Wiki(title, "This is a empty page, start editing the page!", CommunityId); page.Save(User); return(page); } } return(page); }