public async Task <ActionResult> DeleteSchema(string ownerId, string schemaId) { if (string.IsNullOrEmpty(ownerId)) { return(new NotFoundResult()); } if (string.IsNullOrEmpty(schemaId)) { return(new NotFoundResult()); } if (User?.Identity == null || !User.Identity.IsAuthenticated) { return(new UnauthorizedResult()); } var model = new TemplateDeleteModel(schemaId); try { model.Area = "delete"; model.SelectedOwnerId = ownerId; model.SchemaId = schemaId; model.UserId = User.Identity.Name; // check user has permission to admin var isAdmin = await _importService.CheckUserIsAdminOfOwner(User, ownerId); if (!isAdmin) { return(ReturnUnauthorizedView()); } var schemaInfo = await _schemaStore.GetSchemaInfoAsync(ownerId, schemaId); if (schemaInfo == null) { Log.Warning( "Schema validation failed. Could not find a schema info record for schema {0} for owner {1}", model.SchemaId, model.SelectedOwnerId); return(new NotFoundResult()); } model.SchemaInfo = schemaInfo; } catch (Exception ex) { Log.Error(ex, "Error loading delete schema page"); ModelState.AddModelError("", "Error encountered while loading the page"); } return(View(model)); }