public async Task <IActionResult> CreatePost(QueriesCreateViewModel model) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageQueries)) { return(Unauthorized()); } var query = _querySources.FirstOrDefault(x => x.Name == model.SourceName)?.Create(); if (query == null) { return(NotFound()); } var editor = await _displayManager.UpdateEditorAsync(query, this); if (ModelState.IsValid) { await _queryManager.SaveQueryAsync(query); _notifier.Success(H["Query created successfully"]); return(RedirectToAction("Index")); } // If we got this far, something failed, redisplay form model.Editor = editor; return(View(model)); }
public async Task <IActionResult> Create(string id) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageQueries)) { return(Unauthorized()); } var query = _querySources.FirstOrDefault(x => x.Name == id)?.Create(); if (query == null) { return(NotFound()); } var model = new QueriesCreateViewModel { Editor = await _displayManager.BuildEditorAsync(query, this), SourceName = id }; return(View(model)); }