You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.5 KiB
67 lines
1.5 KiB
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace WebApplication1.Controllers
|
|
{
|
|
[Route("api/v1/[controller]")]
|
|
[ApiController]
|
|
public class FieldController : ControllerBase
|
|
{
|
|
private IFieldManager _fm;
|
|
private ILogger<FieldController> _lg;
|
|
|
|
/// <summary>
|
|
/// .ctor
|
|
/// </summary>
|
|
/// <param name="fm"></param>
|
|
public FieldController(
|
|
IFieldManager fm,
|
|
ILogger<FieldController> lg)
|
|
{
|
|
_fm = fm;
|
|
_lg = lg;
|
|
}
|
|
|
|
|
|
|
|
[HttpPost("new")]
|
|
public ActionResult<Field> StartNewGame()
|
|
{
|
|
Field result = _fm.StartNewGame();
|
|
if (result == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(result);
|
|
}
|
|
[HttpPost("move")]
|
|
public ActionResult<Field> Move(string identifier)
|
|
{
|
|
Field result = _fm.Move(identifier);
|
|
if (result == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpGet("list")]
|
|
public ActionResult<Field> List(string identifier)
|
|
{
|
|
var result = _fm.List(identifier);
|
|
if (result == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
return Ok(result);
|
|
}
|
|
|
|
}
|
|
}
|
|
|