Передача данных ASP.NET
Для запуска ботов в игре есть небольшое меню.
@page
@model IndexModel
@{
ViewData["Title"] = "BotDirector";
}
<form method="post">
<div class="row">
<div class="col-md-3">
<h2>Start explorers</h2>
<ul>
<li>
<select name="faction" asp-for="Faction" >
<option selected="true">@(Factions.Sentinels)</option>
<option>@(Factions.Legion)</option>
</select>
<input type="number" asp-for="BotExplorerToStart"/>
<button type="submit" name="action" value="Run">Run</button>
</li>
</ul>
</div>
</div>
</form>
Логика заключена в классе IndexModel
public class IndexModel : PageModel
{
private readonly IBotDirectorService directorService;
private readonly ILogger<IndexModel> logger;
public IndexModel(ILogger<IndexModel> logger, IBotDirectorService directorService)
{
this.logger = logger;
this.directorService = directorService;
}
[BindProperty]
public int BotExplorerToStart { get; set; }
public async Task<IActionResult> OnPostAsync()
{
try
{
await this.directorService.StartBots(this.BotExplorerToStart, BehaviorType.Explorer, this.Faction, masteryLevel: 1);
}
catch (Exception ex)
{
this.logger.Error(ex);
}
return this.RedirectToPage("/Index");
}
}
Я хочу добавить еще одну кнопку для остановки ботов, но при нажатии на новую кнопку он снова добавляет новых ботов. Как сделать так, чтобы другая кнопка выполняла другой функционал?