Example #1
0
        public async Task <IActionResult> Add(ContentTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.ContentTypes = await this._speedWagon.ContentTypeService.List();

                return(View("~/Views/SpeedWagon/ContentType/List.cshtml", model));
            }


            this._speedWagon.ContentTypeService.Add(model.Name, User.Identity.Name.MaskEmail(), model.Root, model.Children);

            if (!string.IsNullOrEmpty(model.CopyProperties))
            {
                SpeedWagonContent contentType = await this._speedWagon.ContentTypeService.Get(model.Name);

                SpeedWagonContent master = await this._speedWagon.ContentTypeService.Get(model.CopyProperties);

                contentType.Content["Editors"] = master.Content["Editors"];

                this._speedWagon.ContentTypeService.Save(contentType, User.Identity.Name.MaskEmail());
            }

            return(RedirectToAction("List", new { id = model.Name }));
        }
Example #2
0
        public async Task <IActionResult> List()
        {
            ContentTypeViewModel viewModel = new ContentTypeViewModel();

            viewModel.ContentTypes = await this._speedWagon.ContentTypeService.List();

            IEnumerable <SpeedWagonContent> contentTypes = await this._speedWagon.ContentTypeService.List();

            viewModel.AvailableContentTypes = SelectListHelper.GetSelectList(contentTypes, true);

            return(View("~/Views/SpeedWagon/ContentType/List.cshtml", viewModel));
        }
        public override async Task <IDisplayResult> UpdateAsync(ContentTypeDefinition contentTypeDefinition, UpdateTypeEditorContext context)
        {
            var model = new ContentTypeViewModel();

            await context.Updater.TryUpdateModelAsync(model, Prefix);

            context.Builder.DisplayedAs(model.DisplayName);

            if (String.IsNullOrWhiteSpace(model.DisplayName))
            {
                context.Updater.ModelState.AddModelError("DisplayName", S["The Content Type name can't be empty."]);
            }

            return(Edit(contentTypeDefinition));
        }
Example #4
0
        public async Task <IHttpActionResult> PostContentType(ContentTypeViewModel contentTypeView)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ContentType contentType = new ContentType();

            contentType.Type      = contentTypeView.Type;
            contentType.Extension = contentTypeView.Extension;
            //contentType.SafetyInstruction= await db.SafetyInstructions.FindAsync(contentTypeView.SafetyInstructionId);
            db.ContentTypes.Add(contentType);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = contentType.ID }, contentType));
        }
Example #5
0
        public ContentTypePage()
        {
            InitializeComponent();

            BindingContext = _viewModel = new ContentTypeViewModel();
        }