Ejemplo n.º 1
0
        public virtual ActionResult Create(string folderName, string parentFolder, string parentUUID, FormCollection form)
        {
            JsonResultEntry resultEntry = new JsonResultEntry() { Success = true };
            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 = ServiceFactory.TextContentManager.Add(Repository, textFolder, parentFolder, parentUUID, form, Request.Files, addedCategories, User.Identity.Name);

                    resultEntry.ReloadPage = true;

                    resultEntry.Success = true;
                }
            }
            catch (RuleViolationException ruleEx)
            {
                foreach (var item in ruleEx.Issues)
                {
                    resultEntry.AddFieldError(item.PropertyName, item.ErrorMessage);
                }
            }
            catch (Exception e)
            {
                resultEntry.SetFailed().AddException(e);
            }
            resultEntry.AddModelState(ViewData.ModelState);
            return Json(resultEntry);
        }