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}); }
/// <summary> /// Toes the CmsPage edit model. /// </summary> /// <returns>a CmsPageEditModel</returns> public static CmsPageEditModel CmsPageToCmsPageEditModel(CmsPage CmsPage) { CmsPageEditModel viewModel = new CmsPageEditModel { 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; }