Beispiel #1
0
        public virtual ActionResult Create(string folderName, string parentFolder, string parentUUID, FormCollection form, string @return)
        {
            var data = new JsonResultData();

            try
            {
                if (ModelState.IsValid)
                {
                    TextFolder textFolder = new TextFolder(Repository, folderName).AsActual();
                    var        schema     = textFolder.GetSchema().AsActual();

                    SchemaPath schemaPath = new SchemaPath(schema);
                    IEnumerable <TextContent> addedCategories;
                    IEnumerable <TextContent> removedCategories;

                    ParseCategories(form, out addedCategories, out removedCategories);
                    ContentBase content;

                    content = TextContentManager.Add(Repository, textFolder, parentFolder, parentUUID, form, Request.Files, addedCategories, User.Identity.Name);

                    data.RedirectUrl = @return;
                }
            }
            catch (RuleViolationException ruleEx)
            {
                foreach (var item in ruleEx.Issues)
                {
                    data.AddFieldError(item.PropertyName, item.ErrorMessage);
                }
            }
            catch (Exception e)
            {
                data.AddException(e);
            }
            data.AddModelState(ModelState);
            return(Json(data));
        }