/// <summary> /// Updates the specified new page. /// </summary> /// <param name="newPage">The new page.</param> public void Update(CmsPage newPage) { this.CategoryId = newPage.CategoryId; this.Title = newPage.Title; }
public ActionResult EditPage(CmsPageEditModel model) { CmsPage page = new CmsPage(); if (cmsPageRepository.Pages.Count(p => p.PageId == model.PageId) > 0) { page = cmsPageRepository.Pages.Where(p => p.PageId == model.PageId).SingleOrDefault(); } page = CmsMapping.CmsPageEditModelToCmsPage(model); cmsPageRepository.SavePage(page); return RedirectToAction("Listpages", new { categoryId = model.CategoryId}); }
public static CmsFieldsViewModel CmsFieldsToCmsFieldsViewModel(IQueryable<CmsField> CmsFields, CmsPage CmsPage, int page = 1, int CmsPageSize = 20) { List<CmsFieldViewModel> listOfCmsFields = new List<CmsFieldViewModel>(); foreach (CmsField CmsField in CmsFields) { listOfCmsFields.Add( new CmsFieldViewModel { FieldId = CmsField.FieldId, Title = CmsField.Title, Content = CmsField.Content }); } CmsFieldsViewModel model = new CmsFieldsViewModel { CmsFields = listOfCmsFields.Where(p => p != null), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = CmsPageSize, TotalItems = listOfCmsFields.Count() }, Page = new CmsPageViewModel { PageId = CmsPage.PageId, CategoryId = CmsPage.CategoryId, Title = CmsPage.Title } }; return model; }
/// <summary> /// Toes the CmsPage view model. /// </summary> /// <returns>a CmsPageViewModel</returns> public static CmsPageViewModel CmsPageToCmsPageViewModel(CmsPage CmsPage) { CmsPageViewModel viewModel = new CmsPageViewModel { PageId = CmsPage.PageId, CategoryId = CmsPage.CategoryId, Title = CmsPage.Title }; return viewModel; }
/// <summary> /// CmsPages to CmsPage edit model. /// </summary> /// <param name="CmsPage">The CmsPage.</param> /// <param name="CmsCategoryList">The CmsCategory list.</param> /// <param name="isNew">if set to <c>true</c> [is new].</param> /// <returns>a CmsPageEditModel</returns> public static CmsPageEditModel CmsPageToCmsPageEditModel(CmsPage CmsPage, Dictionary<int, string> CmsCategoryList, bool isNew) { CmsPageEditModel viewModel = new CmsPageEditModel { PageId = CmsPage.PageId, CategoryId = CmsPage.CategoryId, Title = CmsPage.Title, Categories = CmsCategoryList, New = isNew }; return viewModel; }
/// <summary> /// Froms the CmsPage edit model. /// </summary> /// <param name="model">The model.</param> /// <returns>New CmsPage from CmsPageEditModel</returns> public static CmsPage CmsPageEditModelToCmsPage(CmsPageEditModel model) { CmsPage CmsPage = new CmsPage { Title = model.Title, CategoryId = model.CategoryId }; if (model.PageId != 0) { CmsPage.PageId = model.PageId; } return CmsPage; }