public ActionResult Create(string id1, string id2) { IConfigSet parent = null; if (id1.ContainsCharacters()) { parent = reader.GetConfigSet(id1, id2); } if (parent == null) { if (ConfigReaderFactory.CurrentUser.AdministratorType != AdministratorTypes.SystemAdmin) { throw new UnauthorizedAccessException("Access denied to configset"); } ViewBag.IsNew = true; ViewBag.CreateType = "new"; } else { if (!parent.UserHasAccessTo()) { throw new UnauthorizedAccessException("Access denied to configset"); } ViewBag.IsNew = false; ViewBag.CreateType = string.Format("child for {0}.{1}", id1, id2); } return(View(parent)); }
public ActionResult Create(string id1, string id2, ConfigSet model) { IConfigSet parent = null; if (id1.ContainsCharacters()) { parent = reader.GetConfigSet(id1, id2); if (!parent.UserHasAccessTo()) { throw new UnauthorizedAccessException("Access denied to configset"); } } else { if (ConfigReaderFactory.CurrentUser.AdministratorType != AdministratorTypes.SystemAdmin) { throw new UnauthorizedAccessException("Access denied to configset"); } } reader.CreateConfigSet(model.Name, string.IsNullOrEmpty(model.System) ? id2 : model.System, parent); var csId = reader.GetConfigSet(model.Name, string.IsNullOrEmpty(model.System) ? id2 : model.System); return(RedirectToAction("Details", "ConfigSet", new { name = csId.Name, system = csId.System })); }