Move around response.redirect calls
This commit is contained in:
parent
f9696e17a7
commit
d390bd26fb
|
@ -9,6 +9,8 @@ public class EditModel : PageModel {
|
|||
public void OnGet() { }
|
||||
|
||||
public async void OnPost() {
|
||||
Response.Redirect("/");
|
||||
|
||||
await using var db = new DatabaseContext();
|
||||
var bot = db.Bots.First(p => p.Id == int.Parse(Request.RouteValues["id"]!.ToString()!));
|
||||
|
||||
|
@ -30,7 +32,5 @@ public class EditModel : PageModel {
|
|||
await db.SaveChangesAsync();
|
||||
Task.WhenAny(Task.Run(() => BotOrchestrator.AddBot(bot)), Task.Delay(500)).Wait();
|
||||
}
|
||||
|
||||
Response.Redirect("/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ public class IndexModel : PageModel {
|
|||
public void OnGet() { }
|
||||
|
||||
public async void OnPost() {
|
||||
Response.Redirect("/");
|
||||
|
||||
await using var db = new DatabaseContext();
|
||||
if (Request.Form["action"] == "add_bot") {
|
||||
var bot = new Backend.Database.Tables.Bot {
|
||||
|
@ -21,17 +23,12 @@ public class IndexModel : PageModel {
|
|||
db.Add(bot);
|
||||
await db.SaveChangesAsync();
|
||||
await Task.WhenAny(Task.Run(() => BotOrchestrator.AddBot(bot)), Task.Delay(500));
|
||||
Response.Redirect("/");
|
||||
}
|
||||
else if (Request.Form["action"] == "delete_bot") {
|
||||
var bot = await db.Bots.FindAsync(int.Parse(Request.Form["bot_id"]!));
|
||||
BotOrchestrator.DelBot(bot!);
|
||||
db.Remove(bot!);
|
||||
await db.SaveChangesAsync();
|
||||
Response.Redirect("/");
|
||||
}
|
||||
else {
|
||||
Response.Redirect("/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue