-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeamSelectionController.cs
More file actions
51 lines (49 loc) · 1.78 KB
/
TeamSelectionController.cs
File metadata and controls
51 lines (49 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Contracts;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Models;
using System;
using System.Threading.Tasks;
namespace Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TeamSelectionController : ControllerBase
{
private readonly ITeamSelectionService _teamSelectionService;
public TeamSelectionController(ITeamSelectionService teamSelectionService)
{
_teamSelectionService = teamSelectionService ?? throw new ArgumentNullException(default, nameof(ITeamSelectionService));
}
/// <summary>
/// Compose team based on selection criteria
/// </summary>
/// <remarks>
/// Sample request:
///
/// {
/// "playerHeight": 5.4,
/// "playerBMI": 24,
/// "playerRuns": 7000,
/// "playerWickets": 100,
/// "playerStumpings": 100
/// }
/// </remarks>
/// <param name="selectionCriteriaDto"></param>
/// <returns>Selected team contains 5 batsmen, 5 bowlers and a keeper</returns>
/// <response code="200">Returns the newly created team</response>
/// <response code="400">If the item null</response>
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[HttpPost]
public async Task<ActionResult<SelectedTeam>> CreateTeam([FromBody] SelectionCriteria selectionCriteriaDto)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var selectedTeam = await _teamSelectionService.SelectTalentedPlayersAsync(selectionCriteriaDto);
return Ok(selectedTeam);
}
}
}