Example #1
0
        public ActionResult AddFieldTo(string id)
        {
            if (!Services.Authorizer.Authorize(Permissions.EditContentTypes, T("Not allowed to edit a content part.")))
            {
                return(new HttpUnauthorizedResult());
            }

            var partViewModel = _contentDefinitionService.GetPart(id);

            if (partViewModel == null)
            {
                //id passed in might be that of a type w/ no implicit field
                var typeViewModel = _contentDefinitionService.GetType(id);
                if (typeViewModel != null)
                {
                    partViewModel = new EditPartViewModel(new ContentPartDefinition(id));
                }
                else
                {
                    return(HttpNotFound());
                }
            }

            var viewModel = new AddFieldViewModel {
                Part   = partViewModel,
                Fields = _contentDefinitionService.GetFields().OrderBy(x => x.FieldTypeName)
            };

            return(View(viewModel));
        }
Example #2
0
        public async Task <ActionResult> AddFieldTo(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes))
            {
                return(Unauthorized());
            }

            var partViewModel = _contentDefinitionService.GetPart(id);

            if (partViewModel == null)
            {
                //id passed in might be that of a type w/ no implicit field
                var typeViewModel = _contentDefinitionService.GetType(id);
                if (typeViewModel != null)
                {
                    partViewModel = new EditPartViewModel(new ContentPartDefinition(id));
                }
                else
                {
                    return(NotFound());
                }
            }

            var viewModel = new AddFieldViewModel
            {
                Part   = partViewModel,
                Fields = _contentDefinitionService.GetFields().OrderBy(x => x.FieldTypeName).ToList()
            };

            return(View(viewModel));
        }
Example #3
0
        public async Task <ActionResult> AddFieldTo(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes))
            {
                return(Unauthorized());
            }

            var partViewModel = _contentDefinitionService.GetPart(id);

            if (partViewModel == null)
            {
                return(NotFound());
            }

            var viewModel = new AddFieldViewModel
            {
                Part   = partViewModel.PartDefinition,
                Fields = _contentDefinitionService.GetFields().Select(x => x.Name).OrderBy(x => x).ToList()
            };

            return(View(viewModel));
        }
 private IDictionary <string, Type> GetProductAttributeFieldTypes()
 => _contentDefinitionService
 .GetFields()
 .Where(t => typeof(ProductAttributeField).IsAssignableFrom(t))
 .ToDictionary(t => t.Name);