コード例 #1
0
        /// <summary>
        /// Views the field.
        /// </summary>
        /// <param name="categoryName">Name of the category.</param>
        /// <param name="pageTitle">The page title.</param>
        /// <param name="fieldTitle">The field title.</param>
        /// <returns>Page Content</returns>
        public ActionResult ViewField(string categoryName, string pageTitle, string fieldTitle)
        {
            CmsFieldViewModel model = new CmsFieldViewModel
                                          {
                                              Content = string.Empty
                                          };

            try
            {
                CmsCategory category =
                    cmsCategoryRepository.Categories.Where(c => c.Title == categoryName).SingleOrDefault();

                CmsPage page =
                    cmsPageRepository.Pages.Where(p => p.Title == pageTitle && p.CategoryId == category.CategoryId).
                        SingleOrDefault();

                CmsField field =
                    cmsFieldRepository.CmsFields.Where(f => f.Title == fieldTitle && f.PageId == page.PageId).
                        SingleOrDefault();

                model = new CmsFieldViewModel
                {
                    FieldId = field.FieldId,
                    PageId = field.FieldId,
                    Content = field.Content
                };
            }
            catch
            {
                
            }
            
            return PartialView(model);
        }
コード例 #2
0
        public ActionResult EditField(int fieldId)
        {
            CmsField field = cmsFieldRepository.CmsFields.Where(f => f.FieldId == fieldId).SingleOrDefault();
            CmsPage page = cmsPageRepository.Pages.Where(p => p.PageId == field.PageId).SingleOrDefault();
            
            CmsFieldViewModel model = new CmsFieldViewModel
                                          {
                                              FieldId = field.FieldId,
                                              PageId = field.PageId,
                                              Title = field.Title,
                                              Content = field.Content,
                                              PageName = page.Title
                                          };

            return View(model);
        }
コード例 #3
0
        public ActionResult EditField(CmsFieldViewModel model)
        {
            CmsField field = new CmsField();

            if (cmsFieldRepository.CmsFields.Count(f => f.FieldId == model.FieldId) > 0)
            {
                field = cmsFieldRepository.CmsFields.Where(f => f.FieldId == model.FieldId).SingleOrDefault();
            }

            field = CmsMapping.CmsFieldViewModelToCmsField(model);

            cmsFieldRepository.SaveField(field);
            return RedirectToAction("ListFields", new {pageId = model.PageId});
        }
コード例 #4
0
ファイル: CMSMapping.cs プロジェクト: W1R3D-Code/TheExordium
        public static CmsField CmsFieldViewModelToCmsField(CmsFieldViewModel model)
        {
            CmsField field = new CmsField
            {
                PageId = model.PageId,
                FieldId = model.FieldId,
                Title = model.Title,
                Content = model.Content
            };

            return field;
        }