public async void AddAndGetsPages() { var Page1 = await PageService.AddPage(new Page() { Name = "Page 1" }); var Page2 = await PageService.AddPage(new Page() { Name = "Page 2" }); var Page3 = await PageService.AddPage(new Page() { Name = "Page 3" }); Assert.NotNull(Page1); Assert.NotNull(Page2); Assert.NotNull(Page3); Assert.Equal(1, Page1.Id); Assert.Equal(2, Page2.Id); Assert.Equal(3, Page3.Id); var Pages = await PageService.GetPages(); Assert.NotNull(Pages); Assert.Equal(3, Pages.Length); }
public ActionResult Create(StaticPageModel pageModel) { if (ModelState.IsValid) { try { User user = _authenService.GetAuthenticatedUser(); StaticPage page = pageModel.ToEntity(); page.Created = DateTime.Now; page.Modified = page.Created; page.CreatedBy = user.Id; page.ModifiedBy = page.CreatedBy; _pageService.AddPage(page); return(RedirectToAction("Index")); } catch (Exception e) { ErrorNotification(e.ToString()); } } else { AddModelStateErrors(); } Title = "Thêm mới trang tĩnh"; ViewData["ToolbarTitle"] = Title; return(View()); }
public ActionResult CreatePage(Page page) { if (ModelState.IsValid) { service.AddPage(page); return(RedirectToAction("index")); } return(View(page)); }
public ActionResult New(PageViewModel model) { if (!ModelState.IsValid) { return(View("Edit", model)); } model = _pageService.AddPage(model); return(RedirectToAction("Index", "Wiki", new { id = model.Id })); }
public HttpResponseMessage Post([FromBody] Page page) { if (ModelState.IsValid) { if (!_pageService.AddPage(page)) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); }
public object AddSave(PageInput pageInput) { //TODO: (erikpo) Check permissions ModelResult <Page> results = pageService.AddPage(pageInput); if (!results.IsValid) { ModelState.AddModelErrors(results.ValidationState); return(Add(pageInput)); } return(Redirect(Url.AppPath(Url.Page(results.Item)))); }
public async Task <IActionResult> AddPage([FromBody] AddPageDto addPageDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { addPageDto.UserId = GetUserId(); var text = await _websiteService.GetHtml(addPageDto.Url); if (addPageDto.CheckingType == CheckingTypeEnum.Element) { text = HtmlHelper.GetNode(text, addPageDto.ElementXPath); } WebsiteTextDto primaryText = await _websiteTextService.AddText(new AddWebsiteTextDto() { Text = text }); addPageDto.PrimaryTextId = primaryText.WebsiteTextId; var addResult = await _pageService.AddPage(addPageDto); if (addResult == null) { return(BadRequest()); } return(Ok(addResult)); } catch (UriFormatException) { return(BadRequest()); } catch (WebException) { return(BadRequest()); } catch { return(BadRequest()); } }
public async Task <IActionResult> OnPostAsync(IFormFile postImageUp, string tags) { if (!ModelState.IsValid) { return(Page()); } if (await _pageService.IsPageTitleInBrowserRepeated(Page.PageTitleInBrowser)) { ModelState.AddModelError("Post.PageTitleInBrowser", "قبلا صفحه ای با این عنوان برای مرورگر ثبت شده است!"); return(Page()); } await _pageService.AddPage(Page); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int categoryId, int id) { if (!ModelState.IsValid) { return(Page()); } if (id == 0) { await _pageService.AddPage(categoryId, Page); } else { await _pageService.UpdatePage(Page); } return(RedirectToPage("./Pages", new { categoryId })); }
public async Task <IActionResult> OnPostAsync(int id) { if (!ModelState.IsValid) { return(Page()); } if (id == 0) { await _pageService.AddPage(Page); } else { await _pageService.UpdatePage(Page); } return(RedirectToPage("./Index")); }
public virtual async Task <ActionResult> Add(AddPageViewModel pageModel) { if (!ModelState.IsValid) { pageModel.Pages = await _pageService.GetAllPagesForAdd(); return(View(pageModel)); } var page = new DomainClasses.Page() { PostedByUserId = User.Identity.GetUserId <int>() }; _mappingEngine.Map(pageModel, page); if (pageModel.Id.HasValue) { _pageService.EditPage(page, pageModel.Pages.Select(x => new DomainClasses.Page { Id = x.Id ?? 0, Order = x.Order }).ToList()); TempData["message"] = "برگه مورد نظر با موفقیت ویرایش شد"; } else { _pageService.AddPage(page, pageModel.Pages.Select(x => new DomainClasses.Page { Id = x.Id ?? 0, Order = x.Order }).ToList()); TempData["message"] = "برگه جدید با موفقیت در سیستم ثبت شد"; } await _unitOfWork.SaveAllChangesAsync(); return(RedirectToAction(MVC.Page.Admin.ActionNames.Index)); }
public virtual object SaveAdd(string pagePath, Page pageInput, User currentUser) { string parentPagePath = !string.IsNullOrEmpty(pagePath) ? pagePath.Substring(0, pagePath.Length - ("/" + PageMode.Add).Length) : ""; Page parentPage = pageService.GetPage(parentPagePath); ValidationStateDictionary validationState; Page newPage; pageService.AddPage(pageInput, parentPage, currentUser, out validationState, out newPage); if (!validationState.IsValid) { ModelState.AddModelErrors(validationState); return(Add(pagePath)); } return(Redirect(Url.Page(newPage))); }
/// <summary> /// Creates a new page in the database. /// </summary> /// <param name="model">The page details.</param> public void Post(PageViewModel model) { _pageService.AddPage(model); }
public async Task <IActionResult> AddPage(Page page) { var addedPage = await Pageservice.AddPage(page); return(Ok(addedPage)); }