public ActionResult AddNewPage(AddNewPageViewModel model) { if (ModelState.IsValid) { var response = GetCommand<CreatePageCommand>().ExecuteCommand(model); if (response != null) { response.PageUrl = Http.GetAbsolutePath(response.PageUrl); return Json(new WireJson { Success = true, Data = response }); } } return Json(new WireJson(false)); }
public ActionResult AddNewPage(string parentPageUrl) { AddNewPageViewModel model = new AddNewPageViewModel { ParentPageUrl = parentPageUrl }; model.Templates = GetCommand<GetTemplatesCommand>().ExecuteCommand(new GetTemplatesRequest()).Templates; // Select first template as active if (model.Templates.Count > 0) { model.Templates.ToList().ForEach(x => x.IsActive = false); model.Templates.First().IsActive = true; model.TemplateId = model.Templates.First().TemplateId; } return View(model); }
public void Should_Create_New_Page_With_Access_Rules() { RunActionInTransaction( session => { var tempLayout = TestDataProvider.CreateNewLayout(); session.SaveOrUpdate(tempLayout); session.Flush(); var uow = new DefaultUnitOfWork(session); var repository = new DefaultRepository(uow); var configMock = new Mock<ICmsConfiguration>(); configMock.SetupAllProperties().Setup(f => f.Security.AccessControlEnabled).Returns(true); configMock.Setup(f => f.Security.DefaultAccessRules).Returns(new AccessControlCollection { DefaultAccessLevel = "readwrite" }); var config = configMock.Object; var command = new CreatePageCommand( new Mock<IPageService>().SetupAllProperties().Object, new DefaultUrlService(uow, config), config, new DefaultAccessControlService(Container.Resolve<ISecurityService>(), new HttpRuntimeCacheService(), config), new Mock<IOptionService>().SetupAllProperties().Object); command.UnitOfWork = uow; command.Repository = repository; var request = new AddNewPageViewModel(); request.AccessControlEnabled = true; request.PageTitle = "TestCreatePageCommand"; request.PageUrl = "/test-CreatePageCommand/"; request.TemplateId = tempLayout.Id; request.UserAccessList = new List<UserAccessViewModel>( new[] { new UserAccessViewModel { Identity = "test 1", AccessLevel = AccessLevel.ReadWrite }, new UserAccessViewModel { Identity = "test 2", AccessLevel = AccessLevel.Deny } }); var response = command.Execute(request); session.Clear(); Assert.IsNotNull(response); var page = session.Query<Page>().FirstOrDefault(f => f.Id == response.PageId); Assert.IsNotNull(page); Assert.IsNotNull(page.AccessRules); Assert.AreEqual(2, page.AccessRules.Count()); }); }
public ActionResult AddNewPage(AddNewPageViewModel model) { if (ModelState.IsValid) { var response = GetCommand<CreatePageCommand>().ExecuteCommand(model); if (response != null) { response.PageUrl = HttpUtility.UrlDecode(Http.GetAbsolutePath(response.PageUrl)); Messages.AddSuccess(PagesGlobalization.SavePage_CreatedSuccessfully_Message); return Json(new WireJson { Success = true, Data = response }); } } return Json(new WireJson(false)); }