public async Task PagesControllerHeroBannerJsonReturnsSuccess(string mediaTypeName) { // Arrange var pageRequestModel = new PageRequestModel { Location1 = "a-location-name", Location2 = "an-article-name", }; var expectedResult = new ContentPageModel() { HeroBanner = "This is a hero banner" }; var expectedHeroBanner = new HeroBannerViewModel { Content = new HtmlString(expectedResult.HeroBanner), }; var controller = BuildPagesController(mediaTypeName); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map <HeroBannerViewModel>(A <ContentPageModel> .Ignored)).Returns(expectedHeroBanner); // Act var result = await controller.HeroBanner(pageRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <HeroBannerViewModel>(A <ContentPageModel> .Ignored)).MustHaveHappenedOnceExactly(); var jsonResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsAssignableFrom <HeroBannerViewModel>(jsonResult.Value); Assert.Equal(expectedHeroBanner.Content, model.Content); controller.Dispose(); }
public ActionResult Index(int Id) { ContentPageModel contentPageModel = new ContentPageModel(); contentPageModel.ContentPageId = Id; return(View(contentPageModel)); }
public async Task WebhookContentProcessorProcessContentAsyncForUpdateReturnsBadRequest() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.BadRequest; var expectedValidApiContentModel = BuildValidPagesApiContentModel(); var expectedValidContentPageModel = new ContentPageModel(); var url = new Uri("https://somewhere.com"); var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeCmsApiService.GetItemAsync <CmsApiDataModel>(A <Uri> .Ignored)).Returns(expectedValidApiContentModel); A.CallTo(() => FakeMapper.Map <ContentPageModel>(A <CmsApiDataModel> .Ignored)).Returns(expectedValidContentPageModel); // Act var result = await service.ProcessContentAsync(url, ContentIdForCreate).ConfigureAwait(false); // Assert A.CallTo(() => FakeCmsApiService.GetItemAsync <CmsApiDataModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <ContentPageModel>(A <CmsApiDataModel> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.CreateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventGridService.CompareAndSendEventAsync(A <ContentPageModel> .Ignored, A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened(); Assert.Equal(expectedResponse, result); }
public async Task PagesControllerBreadcrumbHtmlReturnsBoContentForDoNotShwoBradcrumb() { // Arrange var pageRequestModel = new PageRequestModel { Location1 = "a-location-name", Location2 = "an-article-name", }; var expectedResult = new ContentPageModel() { PageLocation = "/" + pageRequestModel.Location1, CanonicalName = pageRequestModel.Location2, ShowBreadcrumb = false }; var controller = BuildPagesController(MediaTypeNames.Text.Html); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); // Act var result = await controller.Breadcrumb(pageRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <BreadcrumbViewModel>(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); var statusResult = Assert.IsType <NoContentResult>(result); A.Equals((int)HttpStatusCode.NoContent, statusResult.StatusCode); controller.Dispose(); }
public async Task PagesControllerBodyWithNullArticleHtmlReturnsSuccess(string mediaTypeName) { // Arrange var pageRequestModel = new PageRequestModel { Location1 = "a-location-name", }; var expectedResult = new ContentPageModel() { Content = "<h1>A document</h1>", PageLocation = "/" + pageRequestModel.Location1, CanonicalName = pageRequestModel.Location2 }; var controller = BuildPagesController(mediaTypeName); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <BodyViewModel> .Ignored)).Returns(A.Fake <BodyViewModel>()); // Act var result = await controller.Body(pageRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <BodyViewModel> .Ignored)).MustHaveHappenedOnceExactly(); var viewResult = Assert.IsType <ViewResult>(result); _ = Assert.IsAssignableFrom <BodyViewModel>(viewResult.ViewData.Model); controller.Dispose(); }
public ActionResult Index() { ContentPageModel contentPage = null; try { if (!ApplicationContext.Getinstance().eCollabroSetupReady) // check for first time { ISetupClient setupClient = ApplicationContext.Getinstance().UnityContainer.Resolve <ISetupClient>(); if (!setupClient.CheckEcollabroSetup()) { TempData["NeedSetup"] = true; return(Redirect("/Setup")); } else { ApplicationContext.Getinstance().eCollabroSetupReady = true; } } contentPage = ContentClientProcessor.GetHomePage(); } catch (Exception ex) { HandleError(ex); } return(View(contentPage)); }
/// <summary> /// 获取评论列表 /// </summary> /// <param name="cid"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public ContentPageModel <CommentModel> GetComment(int cid, int pageIndex, int pageSize) { try { using (qds105749277_dbEntities db = new qds105749277_dbEntities()) { ContentPageModel <CommentModel> model = new ContentPageModel <CommentModel>(); var sql = from a in db.Comment join b in db.Users on a.UserId equals b.Id where a.ContentId == cid orderby a.Time descending select new CommentModel() { ContentId = a.ContentId, Id = a.Id, Text = a.Text, Time = a.Time, UserId = a.UserId, UserName = b.UserName, ZhiChi = a.ZhiChi, FanDui = a.FanDui }; var list = sql.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); model.cList = list; model.Count = sql.Count(); return(model); } } catch (Exception) { throw; } }
public async Task PagesControllerHeadJsonReturnsSuccess(string mediaTypeName) { // Arrange var pageRequestModel = new PageRequestModel { Location1 = "a-location-name", Location2 = "an-article-name", }; var expectedResult = new ContentPageModel() { PageLocation = "/" + pageRequestModel.Location1, CanonicalName = pageRequestModel.Location2 }; var controller = BuildPagesController(mediaTypeName); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <HeadViewModel> .Ignored)).Returns(A.Fake <HeadViewModel>()); // Act var result = await controller.Head(pageRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <HeadViewModel> .Ignored)).MustHaveHappenedOnceExactly(); var jsonResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsAssignableFrom <HeadViewModel>(jsonResult.Value); model.CanonicalUrl.Should().NotBeNull(); controller.Dispose(); }
protected ContentPageModel BuildValidContentPageModel(string?contentType = null) { var model = new ContentPageModel() { Id = ContentIdForUpdate, Etag = Guid.NewGuid().ToString(), CanonicalName = "an-article", IncludeInSitemap = true, Version = Guid.NewGuid(), Url = new Uri("https://localhost"), Content = null, ContentItems = new List <ContentItemModel> { BuildValidContentItemModel(ContentItemIdForCreate), BuildValidContentItemModel(ContentItemIdForUpdate, contentType), BuildValidContentItemModel(ContentItemIdForDelete), }, PageLocations = new List <PageLocationModel> { BuildValidPagesPageLocationModel(PageLocationIdForCreate), BuildValidPagesPageLocationModel(PageLocationIdForUpdate), BuildValidPagesPageLocationModel(PageLocationIdForDelete), }, LastReviewed = DateTime.UtcNow, CreatedDate = DateTime.UtcNow, }; return(model); }
public async Task PagesControllerCallsContentPageServiceUsingPagesRouteForOkResult(string route, string?location1, string?location2, string?location3, string?location4, string?location5, string actionMethod) { // Arrange var pageRequestModel = new PageRequestModel { Location1 = location1, Location2 = location2, Location3 = location3, Location4 = location4, Location5 = location5, }; var controller = BuildController(route); var expectedResult = new ContentPageModel() { Content = "<h1>A document</h1>" }; A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); // Act var result = await RunControllerAction(controller, pageRequestModel, actionMethod).ConfigureAwait(false); // Assert Assert.IsType <OkObjectResult>(result); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); controller.Dispose(); }
public IActionResult ModifyHome() { HotelModel hotelModel = new HotelModel(connectionString); Hotel hotels = hotelModel.GetAllHotel(); HotelModel hotel = new HotelModel(); hotel.id = hotels.id; hotel.name = hotels.name; hotel.description = hotels.description; ContentPageModel contentpageModel = new ContentPageModel(connectionString); IList <ContentPage> content = contentpageModel.GetAllContentPage(); List <ContentPageModel> contentPage = new List <ContentPageModel>(); for (int i = 0; i < content.Count; i++) { if (content[i].referentpage.Equals("home")) { ContentPageModel contentNew = new ContentPageModel(); contentNew.urlimage = content[i].urlimage; contentPage.Add(contentNew); } } ViewBag.contentPage = contentPage; ViewBag.hotel = hotel; return(View()); }
/// <summary> /// 获取评论分页数据 /// </summary> /// <returns></returns> public string GetCommentPageList() { try { int cid = Convert.ToInt32(Request["cid"]); int pageIndex = Convert.ToInt32(Request["pageIndex"] ?? "1"); int pageSize = Convert.ToInt32(Request["pageSize"] ?? "5"); ContentBLL bll = new ContentBLL(); SessionInfo info = (SessionInfo)Session["sessionInfo"]; int userid = 0; if (info != null) { userid = info.userModel.Id; } ContentPageModel <CommentModel> list = bll.GetCommentPageList(cid, pageIndex, pageSize, userid); list.pageThis = pageIndex; var res = JsonConvert.SerializeObject(list); return("success:" + res.ToString()); } catch (Exception ex) { Log.WriteFile(ex); return("faliure:失败"); } }
public IActionResult SaveContentPage(ContentPageModel model) { var contentPage = model.Id > 0 ? _contentPageService.Get(model.Id) : new ContentPage(); if (contentPage == null) { return(NotFound()); } if (model.Published && (model.SeoMeta?.Slug.IsNullEmptyOrWhiteSpace() ?? true)) { if (model.Id > 0) { return(R.Fail.With("error", T("Can't publish page without slug")).Result); } } _modelMapper.Map(model, contentPage, nameof(ContentPage.CreatedOn), nameof(ContentPage.PublishedOn), nameof(ContentPage.UserId)); if (contentPage.Id == 0) { contentPage.CreatedOn = DateTime.UtcNow; contentPage.PublishedOn = model.PublishedOn == default(DateTime) ? DateTime.UtcNow : model.PublishedOn; contentPage.UserId = ApplicationEngine.CurrentUser.Id; } contentPage.UpdatedOn = DateTime.UtcNow; contentPage.ParentId = model.ParentId; _contentPageService.InsertOrUpdate(contentPage); //update the seometa _seoMetaService.UpdateSeoMetaForEntity(contentPage, model.SeoMeta); return(R.Success.With("contentPageId", contentPage.Id).Result); }
public ActionResult Home() { RepositoryContentPage contentpageModel = new RepositoryContentPage(connectionString); IList <ContentPage> content = contentpageModel.GetAllContentPage(); List <ContentPageModel> contentPage = new List <ContentPageModel>(); for (int i = 0; i < content.Count; i++) { if (!content[i].referentpage.Equals("home")) { ContentPageModel contentNew = new ContentPageModel(); contentNew.referentpage = content[i].referentpage; contentNew.urlimage = content[i].urlimage; contentNew.typeimage = content[i].typeimage; contentNew.content = content[i].content; contentPage.Add(contentNew); } } RepositoryHotel hotelModel = new RepositoryHotel(connectionString); Hotel hotels = hotelModel.GetAllHotel(); HotelModel hotel = new HotelModel(); hotel.aboutus = hotels.aboutus; ViewBag.contentPage = contentPage; ViewBag.hotel = hotel; return(View()); }
public async Task PagesControllerHeadReturnsNotAcceptable(string mediaTypeName) { // Arrange var pageRequestModel = new PageRequestModel { Location1 = "a-location-name", Location2 = "an-article-name", }; var expectedResult = new ContentPageModel() { PageLocation = "/" + pageRequestModel.Location1, CanonicalName = pageRequestModel.Location2 }; var controller = BuildPagesController(mediaTypeName); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <HeadViewModel> .Ignored)).Returns(A.Fake <HeadViewModel>()); // Act var result = await controller.Head(pageRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <HeadViewModel> .Ignored)).MustHaveHappenedOnceExactly(); var statusResult = Assert.IsType <StatusCodeResult>(result); A.Equals((int)HttpStatusCode.NotAcceptable, statusResult.StatusCode); controller.Dispose(); }
public IActionResult Index() { /***********************UNO POR UNO****************/ RepositoryHotel hotelModel = new RepositoryHotel(connectionString); Hotel hotels = hotelModel.GetAllHotel(); HotelModel hotel = new HotelModel(); hotel.name = hotels.name; hotel.description = hotels.description; hotel.address = hotels.address; /***************************************************/ RepositoryContentPage contentpageModel = new RepositoryContentPage(connectionString); IList <ContentPage> content = contentpageModel.GetAllContentPage(); List <ContentPageModel> contentPage = new List <ContentPageModel>(); for (int i = 0; i < content.Count; i++) { if (content[i].referentpage.Equals("home")) { ContentPageModel contentNew = new ContentPageModel(); contentNew.referentpage = content[i].referentpage; contentNew.urlimage = content[i].urlimage; contentNew.typeimage = content[i].typeimage; contentNew.content = content[i].content; contentPage.Add(contentNew); } } ViewBag.contentPage = contentPage; ViewBag.allContentPage = contentpageModel.GetAllContentPage(); ViewBag.hotel = hotel; return(View()); }
public HttpResponseMessage GetPage(int siteId, int pageId) { ContentClientProcessor.UserContext.SiteId = siteId; ContentPageModel contentPage = ContentClientProcessor.GetContentPage(pageId); return(Request.CreateResponse(HttpStatusCode.OK, contentPage)); }
public async void PagesControllerBodyWithNullArticleHtmlReturnsSuccess(string mediaTypeName) { // Arrange const string article = null; var expectedResult = new ContentPageModel() { Content = "<h1>A document ({0})</h1>" }; var controller = BuildPagesController(mediaTypeName); expectedResult.CanonicalName = article; A.CallTo(() => FakeContentPageService.GetByNameAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <BodyViewModel> .Ignored)).Returns(A.Fake <BodyViewModel>()); // Act var result = await controller.Body(PagesController.CategoryNameForHelp, article).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentPageService.GetByNameAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <BodyViewModel> .Ignored)).MustHaveHappenedOnceExactly(); var viewResult = Assert.IsType <ViewResult>(result); _ = Assert.IsAssignableFrom <BodyViewModel>(viewResult.ViewData.Model); controller.Dispose(); }
public async void PagesControllerBodyReturnsNotAcceptable(string mediaTypeName) { // Arrange const string article = "an-article-name"; var expectedResult = new ContentPageModel() { Content = "<h1>A document ({0})</h1>" }; var controller = BuildPagesController(mediaTypeName); expectedResult.CanonicalName = article; A.CallTo(() => FakeContentPageService.GetByNameAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <BodyViewModel> .Ignored)).Returns(A.Fake <BodyViewModel>()); // Act var result = await controller.Body(PagesController.CategoryNameForAlert, article).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentPageService.GetByNameAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map(A <ContentPageModel> .Ignored, A <BodyViewModel> .Ignored)).MustHaveHappenedOnceExactly(); var statusResult = Assert.IsType <StatusCodeResult>(result); A.Equals((int)HttpStatusCode.NotAcceptable, statusResult.StatusCode); controller.Dispose(); }
public async void PagesControllerBodyHtmlReturnsRedirectWhenAlternateArticleExistsForDefaultArticleName(string mediaTypeName) { // Arrange const string article = null; ContentPageModel expectedResult = null; var expectedAlternativeResult = A.Fake <ContentPageModel>(); var controller = BuildPagesController(mediaTypeName); A.CallTo(() => FakeContentPageService.GetByNameAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeContentPageService.GetByAlternativeNameAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedAlternativeResult); // Act var result = await controller.Body(PagesController.CategoryNameForAlert, article).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentPageService.GetByNameAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeContentPageService.GetByAlternativeNameAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); var statusResult = Assert.IsType <RedirectResult>(result); statusResult.Url.Should().NotBeNullOrWhiteSpace(); A.Equals(true, statusResult.Permanent); controller.Dispose(); }
public async Task <IActionResult> Update([FromBody] ContentPageModel upsertContentPageModel) { logger.LogInformation($"{nameof(Update)} has been called"); if (upsertContentPageModel == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var existingDocument = await contentPageService.GetByIdAsync(upsertContentPageModel.DocumentId).ConfigureAwait(false); if (existingDocument == null) { return(new StatusCodeResult((int)HttpStatusCode.NotFound)); } if (upsertContentPageModel.SequenceNumber <= existingDocument.SequenceNumber) { return(new StatusCodeResult((int)HttpStatusCode.AlreadyReported)); } upsertContentPageModel.Etag = existingDocument.Etag; upsertContentPageModel.Category = existingDocument.Category; var response = await contentPageService.UpsertAsync(upsertContentPageModel).ConfigureAwait(false); logger.LogInformation($"{nameof(Update)} has upserted content for: {upsertContentPageModel.Category}/{upsertContentPageModel.CanonicalName} with response code {response}"); return(new StatusCodeResult((int)response)); }
public async Task IndexWhenNoDateInApiReturnsData() { // arrange var expectedContentPageModel1 = new ContentPageModel { Id = Guid.NewGuid(), CanonicalName = "test-test", PageLocation = "/top-of-the-tree", RedirectLocations = new List <string> { "/test/test", }, Url = new Uri("http://www.test.com"), }; var expectedContentPageModel2 = new ContentPageModel { Id = Guid.NewGuid(), CanonicalName = "default-page", PageLocation = "/top-of-the-tree", IsDefaultForPageLocation = true, RedirectLocations = new List <string> { "/test/test", }, Url = new Uri("http://www.test.com"), }; var expectedContentPageModels = new List <ContentPageModel> { expectedContentPageModel1, expectedContentPageModel2, }; var expectedGetIndexModel1 = new GetIndexModel { Id = expectedContentPageModel1.Id, Locations = expectedContentPageModel1.RedirectLocations, }; var expectedGetIndexModel2 = new GetIndexModel { Id = expectedContentPageModel2.Id, Locations = expectedContentPageModel2.RedirectLocations, }; A.CallTo(() => fakeContentPageService.GetAllAsync(A <string> .Ignored)).Returns(expectedContentPageModels); using var controller = new ApiController(logger, fakeContentPageService, fakeMapper); A.CallTo(() => fakeMapper.Map <GetIndexModel>(expectedContentPageModel1)).Returns(expectedGetIndexModel1); A.CallTo(() => fakeMapper.Map <GetIndexModel>(expectedContentPageModel2)).Returns(expectedGetIndexModel2); // act var result = await controller.Index().ConfigureAwait(false) as OkObjectResult; // assert A.CallTo(() => fakeContentPageService.GetAllAsync(A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeMapper.Map <GetIndexModel>(expectedContentPageModel1)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeMapper.Map <GetIndexModel>(expectedContentPageModel2)).MustHaveHappenedOnceExactly(); Assert.NotNull(result); Assert.IsType <Dictionary <Guid, GetIndexModel> >(result !.Value); Assert.NotEmpty(result.Value as Dictionary <Guid, GetIndexModel>); }
public ActionResult Facility() { ContentPageModel cp = new ContentPageModel(connectionString); List <ContentPage> contentfacility = cp.GetContentPageFacility("facility"); ViewBag.contentPage = contentfacility; return(View()); }
private List <ValidationResult> Validate(ContentPageModel model) { var vr = new List <ValidationResult>(); var vc = new ValidationContext(model); Validator.TryValidateObject(model, vc, vr, true); return(vr); }
public async Task <HttpStatusCode> UpsertAsync(ContentPageModel contentPageModel) { if (contentPageModel == null) { throw new ArgumentNullException(nameof(contentPageModel)); } return(await repository.UpsertAsync(contentPageModel).ConfigureAwait(false)); }
public ContentPageViewModel(CompendiumModel compendium, ContentPageModel model) : base(model.Header) { _Compendium = compendium; _Model = model; foreach (FilterGroup group in _Model.FilterGroups) { _FilterGroups.Add(new FilterGroupViewModel(group)); } }
private ContentPageModel BuildContentPageModel() { var item = new ContentPageModel { Id = Guid.NewGuid(), CanonicalName = "a-canonical-name", MetaTags = new Compui.Cosmos.Models.MetaTagsModel { Title = "A page title", }, IsDefaultForPageLocation = false, PageLocations = new List <PageLocationModel> { new PageLocationModel { ItemId = Guid.NewGuid(), ContentType = Constants.ContentTypePageLocation, BreadcrumbLinkSegment = "segment-3", BreadcrumbText = "Segment #3", PageLocations = new List <PageLocationModel> { new PageLocationModel { ItemId = Guid.NewGuid(), ContentType = Constants.ContentTypePageLocation, BreadcrumbLinkSegment = "segment-2", BreadcrumbText = "Segment #2", PageLocations = new List <PageLocationModel> { new PageLocationModel { ItemId = Guid.NewGuid(), ContentType = Constants.ContentTypePageLocation, BreadcrumbLinkSegment = "segment-1", BreadcrumbText = "Segment #1", PageLocations = new List <PageLocationModel> { new PageLocationModel { ItemId = Guid.NewGuid(), ContentType = Constants.ContentTypePageLocation, BreadcrumbLinkSegment = "/", BreadcrumbText = "Home", }, }, }, }, }, }, }, }, }; return(item); }
public ActionResult ContentPages() { var grid = new ContentPagesGrid(_contentPageService.Queryable().OrderByDescending(x => x.Created)); var model = new ContentPageModel() { Grid = grid }; return View(model); }
public void CacheReloadServiceTryValidateModelForValidAndInvalid(ContentPageModel contentPageModel, bool expectedResult) { // arrange var cacheReloadService = new CacheReloadService(fakeLogger, fakeMapper, fakeEventMessageService, fakeCmsApiService, fakeContentCacheService, fakeAppRegistryService, fakeContentTypeMappingService, fakeApiCacheService); // act var result = cacheReloadService.TryValidateModel(contentPageModel); // assert A.Equals(result, expectedResult); }
public void EventMessageServiceExtractPageLocationReturnsnullForMissingContentItems() { // arrange var contentPageModel = new ContentPageModel(); var eventMessageService = new EventMessageService <ContentPageModel>(fakeLogger, fakeContentPageService); // act var result = eventMessageService.ExtractPageLocation(contentPageModel); // assert Assert.Null(result); }