public ActionResult EditRule(HiveId id) { Mandate.ParameterNotEmpty(id, "id"); //The rule Id consists of both the stylesheet Id and the rule name var idParts = id.StringParts().ToList(); var stylesheetId = idParts[0]; var ruleName = idParts.Count > 1 ? idParts[1] : ""; ViewBag.IsNew = string.IsNullOrWhiteSpace(ruleName); using (var uow = _hive.Create()) { var stylesheet = uow.Repositories.Get <Umbraco.Framework.Persistence.Model.IO.File>(new HiveId(stylesheetId)); var rule = !string.IsNullOrWhiteSpace(ruleName) ? StylesheetHelper.ParseRules(stylesheet).Single(x => x.Name.Replace(" ", "__s__") == ruleName) : new StylesheetRule() { StylesheetId = id }; var ruleModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <StylesheetRuleEditorModel>(rule); return(View(ruleModel)); } }
public ActionResult DeleteRule(HiveId id) { Mandate.ParameterNotEmpty(id, "id"); var idParts = id.StringParts().ToList(); var stylesheetId = idParts[0]; var ruleName = idParts[1]; using (var uow = _hive.Create()) { var repo = uow.Repositories; var stylesheet = repo.Get <Umbraco.Framework.Persistence.Model.IO.File>(new HiveId(stylesheetId)); StylesheetHelper.ReplaceRule(stylesheet, ruleName, null); repo.AddOrUpdate(stylesheet); uow.Complete(); } //return a successful JSON response return(Json(new { message = "Success" })); }
public ActionResult EditRule(HiveId id) { Mandate.ParameterNotEmpty(id, "id"); //The rule Id consists of both the stylesheet Id and the rule name var idParts = id.StringParts().ToList(); var stylesheetId = idParts[0]; var ruleName = idParts.Count > 1 ? idParts[1] : ""; ViewBag.IsNew = string.IsNullOrWhiteSpace(ruleName); using (var uow = _hive.Create()) { var stylesheet = uow.Repositories.Get<Umbraco.Framework.Persistence.Model.IO.File>(new HiveId(stylesheetId)); var rule = !string.IsNullOrWhiteSpace(ruleName) ? StylesheetHelper.ParseRules(stylesheet).Single(x => x.Name.Replace(" ", "__s__") == ruleName) : new StylesheetRule() { StylesheetId = id }; var ruleModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map<StylesheetRuleEditorModel>(rule); return View(ruleModel); } }
public ActionResult DeleteRule(HiveId id) { Mandate.ParameterNotEmpty(id, "id"); var idParts = id.StringParts().ToList(); var stylesheetId = idParts[0]; var ruleName = idParts[1]; using (var uow = _hive.Create()) { var repo = uow.Repositories; var stylesheet = repo.Get<Umbraco.Framework.Persistence.Model.IO.File>(new HiveId(stylesheetId)); StylesheetHelper.ReplaceRule(stylesheet, ruleName, null); repo.AddOrUpdate(stylesheet); uow.Complete(); } //return a successful JSON response return Json(new { message = "Success" }); }