Update doc and todo (#4)

* Updade doc

* Updade doc
This commit is contained in:
Oda
2024-07-20 21:33:50 +07:00
committed by GitHub
parent a43e560d3a
commit 743d04e6c5
12 changed files with 483 additions and 71 deletions

View File

@@ -7,6 +7,11 @@ using static Managing.Common.Enums;
namespace Managing.Api.Controllers;
/// <summary>
/// Controller for managing scenarios and strategies within the application.
/// Provides endpoints for creating, retrieving, and deleting scenarios and strategies.
/// Requires authorization for access and produces JSON responses.
/// </summary>
[ApiController]
[Authorize]
[Route("[controller]")]
@@ -14,30 +19,53 @@ namespace Managing.Api.Controllers;
public class ScenarioController : ControllerBase
{
private readonly IScenarioService _scenarioService;
/// <summary>
/// Initializes a new instance of the <see cref="ScenarioController"/> class.
/// </summary>
/// <param name="scenarioService">The service for managing scenarios.</param>
public ScenarioController(IScenarioService scenarioService)
{
_scenarioService = scenarioService;
}
/// <summary>
/// Retrieves all scenarios.
/// </summary>
/// <returns>A list of scenarios.</returns>
[HttpGet]
public ActionResult<IEnumerable<Scenario>> GetScenarios()
{
return Ok(_scenarioService.GetScenarios());
}
/// <summary>
/// Creates a new scenario with the specified name and strategies.
/// </summary>
/// <param name="name">The name of the scenario.</param>
/// <param name="strategies">A list of strategy names to include in the scenario.</param>
/// <returns>The created scenario.</returns>
[HttpPost]
public ActionResult<Scenario> CreateScenario(string name, List<string> strategies)
{
return Ok(_scenarioService.CreateScenario(name, strategies));
}
/// <summary>
/// Deletes a scenario by name.
/// </summary>
/// <param name="name">The name of the scenario to delete.</param>
/// <returns>An ActionResult indicating the outcome of the operation.</returns>
[HttpDelete]
public ActionResult DeleteScenario(string name)
{
return Ok(_scenarioService.DeleteScenario(name));
}
/// <summary>
/// Retrieves all strategies.
/// </summary>
/// <returns>A list of strategies.</returns>
[HttpGet]
[Route("strategy")]
public ActionResult<IEnumerable<Strategy>> GetStrategies()
@@ -45,6 +73,21 @@ public class ScenarioController : ControllerBase
return Ok(_scenarioService.GetStrategies());
}
/// <summary>
/// Creates a new strategy with specified parameters.
/// </summary>
/// <param name="strategyType">The type of the strategy.</param>
/// <param name="timeframe">The timeframe for the strategy.</param>
/// <param name="name">The name of the strategy.</param>
/// <param name="period">The period for the strategy (optional).</param>
/// <param name="fastPeriods">The fast periods for the strategy (optional).</param>
/// <param name="slowPeriods">The slow periods for the strategy (optional).</param>
/// <param name="signalPeriods">The signal periods for the strategy (optional).</param>
/// <param name="multiplier">The multiplier for the strategy (optional).</param>
/// <param name="stochPeriods">The stochastic periods for the strategy (optional).</param>
/// <param name="smoothPeriods">The smooth periods for the strategy (optional).</param>
/// <param name="cyclePeriods">The cycle periods for the strategy (optional).</param>
/// <returns>The created strategy.</returns>
[HttpPost]
[Route("strategy")]
public ActionResult<Strategy> CreateStrategy(
@@ -74,10 +117,15 @@ public class ScenarioController : ControllerBase
cyclePeriods));
}
/// <summary>
/// Deletes a strategy by name.
/// </summary>
/// <param name="name">The name of the strategy to delete.</param>
/// <returns>An ActionResult indicating the outcome of the operation.</returns>
[HttpDelete]
[Route("strategy")]
public ActionResult DeleteStrategy(string name)
{
return Ok(_scenarioService.DeleteStrategy(name));
}
}
}