public ActionResult AddModule(string name) { ModuleRepository repo = new ModuleRepository(); string message = string.Empty; bool errored = false; if (string.IsNullOrEmpty(name)) { errored = true; message = "Missing value"; } else { try { repo.AddModule(name); } catch (Exception exc) { errored = true; message = exc.ToString(); } } if (!errored) { message = "Changes Saved"; } return(Json(new { Errored = errored, Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult Add(string token, int workspaceId, [FromBody] Module value) { var user = _auth.AuthenticateForWorkspace(token, workspaceId); if (string.IsNullOrEmpty(value.name)) { throw new ArgumentException(nameof(value.name)); } //var ws = new Workspace(value); _repo.AddModule(value, workspaceId, user); return(Json(new { success = true, data = value })); }