Ejemplo n.º 1
0
        protected override DriverResult Editor(ImageProfilePart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var currentName = part.Name;
            var viewModel   = new ImageProfileViewModel();

            // It would be nice if IUpdateModel provided access to the IsValid property of the Controller, instead of having to track a local flag.
            var isValid = updater.TryUpdateModel(viewModel, Prefix, null, null);

            if (String.IsNullOrWhiteSpace(viewModel.Name))
            {
                updater.AddModelError("Name", T("The Name can't be empty."));
                isValid = false;
            }
            if (currentName != viewModel.Name && _imageProfileService.GetImageProfileByName(viewModel.Name) != null)
            {
                updater.AddModelError("Name", T("A profile with the same Name already exists."));
                isValid = false;
            }
            if (viewModel.Name != viewModel.Name.ToSafeName())
            {
                updater.AddModelError("Name", T("The Name can only contain letters and numbers without spaces"));
                isValid = false;
            }

            if (isValid)
            {
                part.Name = viewModel.Name;
            }

            return(Editor(part, shapeHelper));
        }
Ejemplo n.º 2
0
        protected override DriverResult Editor(ImageProfilePart part, dynamic shapeHelper)
        {
            var viewModel = new ImageProfileViewModel {
                Name = part.Name
            };

            return(ContentShape("Parts_MediaProcessing_ImageProfile_Edit",
                                () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: viewModel, Prefix: Prefix)));
        }