refactor mostly..
This commit is contained in:
parent
63913b432c
commit
3d3ce211b3
|
|
@ -17,7 +17,7 @@ namespace ProjectGrid.Controllers
|
||||||
private readonly ILogger<TicTacTocController> _logger;
|
private readonly ILogger<TicTacTocController> _logger;
|
||||||
|
|
||||||
//static readonly Models.IUserRepository repository = new Models.UserRepository();
|
//static readonly Models.IUserRepository repository = new Models.UserRepository();
|
||||||
private readonly Models.IUserRepository repository;
|
private readonly ITicTacToctRepository repository;
|
||||||
|
|
||||||
public TicTacTocController(ILogger<TicTacTocController> logger, DataAccessContext context)
|
public TicTacTocController(ILogger<TicTacTocController> logger, DataAccessContext context)
|
||||||
{
|
{
|
||||||
|
|
@ -27,15 +27,15 @@ namespace ProjectGrid.Controllers
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("api/ttt/GetBoard")]
|
[Route("api/ttt/GetBoard")]
|
||||||
public IEnumerable<Models.UserModel> GetAllUsers()
|
public Models.TicTacTocBoard GetBoard()
|
||||||
{
|
{
|
||||||
return repository.GetAll();
|
return repository.GetBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("api/ttt/SetPiece")]
|
[Route("api/ttt/SetPiece")]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
public Models.UserModel PostUser(Models.UserModel item)
|
public Models.UserModel PostMove(Models.UserModel item)
|
||||||
{
|
{
|
||||||
return repository.Add(item);
|
return repository.Add(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace ProjectGrid.Controllers
|
||||||
private readonly ILogger<UsersController> _logger;
|
private readonly ILogger<UsersController> _logger;
|
||||||
|
|
||||||
//static readonly Models.IUserRepository repository = new Models.UserRepository();
|
//static readonly Models.IUserRepository repository = new Models.UserRepository();
|
||||||
private readonly Models.IUserRepository repository;
|
private readonly IUserRepository repository;
|
||||||
|
|
||||||
public UsersController(ILogger<UsersController> logger, DataAccessContext context)
|
public UsersController(ILogger<UsersController> logger, DataAccessContext context)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ProjectGrid.Models;
|
||||||
|
|
||||||
|
|
||||||
|
namespace ProjectGrid.Data
|
||||||
|
{
|
||||||
|
public partial class DataAccessContext : ITicTacToctRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
public bool AddPiece(TicTacTocMove user)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Models.TicTacTocBoard GetBoard()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
using ProjectGrid.Models;
|
||||||
|
|
||||||
|
namespace ProjectGrid.Data
|
||||||
|
{
|
||||||
|
public interface ITicTacToctRepository
|
||||||
|
{
|
||||||
|
TicTacTocBoard GetBoard();
|
||||||
|
|
||||||
|
bool AddPiece(TicTacTocMove user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using ProjectGrid.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ProjectGrid.Data
|
||||||
|
{
|
||||||
|
public interface IUserRepository
|
||||||
|
{
|
||||||
|
IEnumerable<UserModel> GetAll();
|
||||||
|
|
||||||
|
UserModel Add(UserModel user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using ProjectGrid;
|
||||||
|
using ProjectGrid.Data;
|
||||||
|
using ProjectGrid.Models;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ProjectGrid
|
||||||
|
{
|
||||||
|
public class TicTacTocManager
|
||||||
|
{
|
||||||
|
|
||||||
|
private ITicTacToctRepository _repo;
|
||||||
|
|
||||||
|
private TicTacTocBoard _board;
|
||||||
|
|
||||||
|
public TicTacTocManager(ITicTacToctRepository repo)
|
||||||
|
{
|
||||||
|
_repo = repo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace ProjectGrid.Models
|
|
||||||
{
|
|
||||||
public interface IUserRepository
|
|
||||||
{
|
|
||||||
IEnumerable<UserModel> GetAll();
|
|
||||||
|
|
||||||
UserModel Add(UserModel user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using ProjectGrid.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.17.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.17.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue