public IActionResult CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFileModel model) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrWhiteSpace(model.Filename)) { throw new ArgumentException("Filename cannot be null or whitespace", "model.Filename"); } if (string.IsNullOrWhiteSpace(model.VirtualPath)) { throw new ArgumentException("VirtualPath cannot be null or whitespace", "model.VirtualPath"); } var macroName = model.Filename.TrimEnd(".cshtml"); var macro = new Macro(_shortStringHelper) { Alias = macroName.ToSafeAlias(_shortStringHelper), Name = macroName, MacroSource = model.VirtualPath.EnsureStartsWith("~") }; _macroService.Save(macro); // may throw return(Ok()); }
public HttpResponseMessage CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFileModel model) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrWhiteSpace(model.Filename)) { throw new ArgumentException("Filename cannot be null or whitespace", "model.Filename"); } if (string.IsNullOrWhiteSpace(model.VirtualPath)) { throw new ArgumentException("VirtualPath cannot be null or whitespace", "model.VirtualPath"); } var macroName = model.Filename.TrimEnd(".cshtml"); var macro = new Macro { Alias = macroName.ToSafeAlias(), Name = macroName, ScriptPath = model.VirtualPath.EnsureStartsWith("~") }; Services.MacroService.Save(macro); // may throw return(new HttpResponseMessage(HttpStatusCode.OK)); }