public WebPage AddOrSavePage(string title, string body, int pageid) { if (title.IsNullOrEmpty()) { throw new Exception("Name cannot be null or empty."); } if (body.IsNullOrEmpty()) { throw new Exception("Conent cannot be null or empty."); } WebPage page = WebPage.FindFirst(x => x.Id == pageid); if (page == null) { page = new WebPage(title, body); } else { page.Title = title; page.Body = body; } page.SavePage(sender.User); return(page); }
public WebMenu AddOrSaveMenu(string name, string icon, int pageid) { if (name.IsNullOrEmpty()) { throw new Exception("Name cannot be null or empty."); } if (icon.IsNullOrEmpty()) { throw new Exception("Icon cannot be null or empty."); } WebPage page = WebPage.FindFirst(x => x.Id == pageid); if (page == null) { throw new Exception("Could not find webpage for that Id."); } WebMenu menu = WebMenu.FindFirst(x => x.name == name); if (menu == null) { if (menu != null) { throw new Exception("Menu button with same name already exist."); } menu = new WebMenu(pageid, name, icon); } else { menu.name = name; menu.icon = icon; menu.PageId = pageid; } menu.SaveMenu(sender.User); return(menu); }