Ejemplo n.º 1
0
        public ActionResult Raw(int id, string xmlData, string next)
        {
            var version = Entities().VariantVersions.Find(id);
            if (version == null)
                return HttpNotFound();

            UserService users = GetService<UserService>();
            if (!users.IsAllowedToEdit(version.Variant, User.Identity.Name))
                return new HttpUnauthorizedResult();

            DefinitionService definitions = GetService<DefinitionService>();
            string errors;
            if (!definitions.ValidateXml(xmlData, out errors))
            {
                ModelState.AddModelError("data", "Error validating XML data: " + errors);

                var model = new RawModel(version);
                model.XmlData = xmlData;
                return View(model);
            }

            version.Definition = xmlData;
            Entities().SaveChanges();

            if (next == "done")
                return RedirectToAction("Edit", "Variants", new { id = version.VariantID });

            return RedirectToAction("Raw", new { id });
        }
Ejemplo n.º 2
0
        public ActionResult Raw(int id)
        {
            var version = Entities().VariantVersions.Find(id);
            if (version == null)
                return HttpNotFound();

            UserService users = GetService<UserService>();
            if (!users.IsAllowedToEdit(version.Variant, User.Identity.Name))
                return new HttpUnauthorizedResult();

            DefinitionService definitions = GetService<DefinitionService>();
            var model = new RawModel(version);

            return View(model);
        }