public async Task <bool> AddPage(NewPageInputModel pageInput) { var page = new SitePages(); page.Title = pageInput.Title; page.Content = pageInput.Content; page.ImageUrl = pageInput.ImageUrl; page.CreatedOn = DateTime.UtcNow; try { await this.db.SitePages.AddAsync(page); } catch (NullReferenceException e) { throw new NullReferenceException("Add Page Needs a valid page model."); } int result = await this.db.SaveChangesAsync(); if (!(result == 0)) { return(false); } return(true); }
public IActionResult NewPage(NewPageInputModel model) { if (ModelState.IsValid) { var user = GetCurrentUser(User.GetUserId()).Result; pageService.CreateNewPage(model.Name, model.Content, user); //Log //[UserName] created new page: {0} string content = string.Format("{0} created new page: {1}", GetCurrentUserName(User.GetUserId()), model.Name); logsService.AddNewLog("Create", content); return(RedirectToAction("EditStaticPages", new { pageName = model.Name })); } else { return(View()); } }
public EditPageModel NewPage(NewPageInputModel newPageInputModel) { return(Post <EditPageModel, NewPageInputModel>("mod_wiki_new_page", newPageInputModel)); }