示例#1
0
        public ActionResult Edit(string contentTypeFullName, string propertyFullName = null)
        {
            //TODO: Validation, etc.
            //TODO: BaseContentType
            contentTypeFullName = _reflectionContentManager.GetContentTypeFullNameFromPropertyFullName(propertyFullName) ?? contentTypeFullName;

            ContentType contentType = null;

            if (!contentTypeFullName.IsNullOrEmpty())
            {
                contentType = _reflectionContentManager.LoadContentType(contentTypeFullName);
            }

            if (contentType == null)
            {
                throw new NotImplementedException();
            }

            IContentTypeProperty contentTypeProperty = null;

            if (!propertyFullName.IsNullOrEmpty())
            {
                contentType.TryGetProperty(propertyFullName, out contentTypeProperty);
            }

            var viewModel = new PropertyEditorViewModelBase();

            if (contentTypeProperty != null)
            {
                viewModel.Name = contentTypeProperty.Name;
            }

            //viewModel.GetPropertyEditorValues = () => contentType.Module.ContentTypes.Select(ct => new MultiSelectListItem
            //        {
            //            GroupKey = ct.Module.Id.ToString(),
            //            GroupName = ct.Module.Name,
            //            Text = ct.Name,
            //            Value = ct.Id.ToString()
            //        });

            viewModel.GetPropertyEditorValues = new[] { new SelectListItem {
                                                            Text = "", Value = ""
                                                        } }
            .Union(_propertyEditorRepository.GetAll().Select(p =>
                                                             new SelectListItem {
                Text = p.Name, Value = p.GetRoute + ";" + p.PostRoute
            })).ToArray();

            viewModel.ContentTypeFullName = contentType.FullName;

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Edit", viewModel));
            }

            return(View(viewModel));
        }
示例#2
0
 private SelectListItem[] GetPropertyEditorValues()
 {
     return(new[] { new SelectListItem {
                        Text = "", Value = ""
                    } }
            .Union(_propertyEditorRepository.GetAll().Select(p =>
                                                             new SelectListItem {
         Text = p.Name, Value = p.GetRoute + ";" + p.PostRoute
     })).ToArray());
 }