From d3cdc93c1431b74145b1409ebf908e446ffa1282 Mon Sep 17 00:00:00 2001 From: Darkstack <1835601+darkstack@users.noreply.github.com> Date: Sat, 6 Oct 2018 13:05:38 +0200 Subject: [PATCH] Ordering files --- .../LaDOSE.Api/Controllers/GameController.cs | 2 +- .../LaDOSE.Api/Controllers/UsersController.cs | 53 +++++++------------ LaDOSE.Src/LaDOSE.Api/LaDOSE.Api.csproj | 2 + LaDOSE.Src/LaDOSE.Api/Startup.cs | 8 +-- .../Context/LaDOSEDbContext.cs | 11 ++-- LaDOSE.Src/LaDOSE.Entity/LaDOSE.Entity.csproj | 4 ++ LaDOSE.Src/LaDOSE.Entity/Season.cs | 15 ++++++ .../LaDOSE.Service/Interface/IUserService.cs | 15 ++++++ .../LaDOSE.Service/LaDOSE.Business.csproj | 13 +++++ .../Service}/UserService.cs | 15 ++---- LaDOSE.Src/LaDOSE.sln | 6 +++ 11 files changed, 89 insertions(+), 55 deletions(-) rename LaDOSE.Src/{LaDOSE.Api => LaDOSE.Entity}/Context/LaDOSEDbContext.cs (76%) create mode 100644 LaDOSE.Src/LaDOSE.Entity/Season.cs create mode 100644 LaDOSE.Src/LaDOSE.Service/Interface/IUserService.cs create mode 100644 LaDOSE.Src/LaDOSE.Service/LaDOSE.Business.csproj rename LaDOSE.Src/{LaDOSE.Api/Services => LaDOSE.Service/Service}/UserService.cs (92%) diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/GameController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/GameController.cs index aeb53cd..259eb36 100644 --- a/LaDOSE.Src/LaDOSE.Api/Controllers/GameController.cs +++ b/LaDOSE.Src/LaDOSE.Api/Controllers/GameController.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using LaDOSE.Api.Context; using LaDOSE.Entity; +using LaDOSE.Entity.Context; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/LaDOSE.Src/LaDOSE.Api/Controllers/UsersController.cs b/LaDOSE.Src/LaDOSE.Api/Controllers/UsersController.cs index 28d6958..19c865b 100644 --- a/LaDOSE.Src/LaDOSE.Api/Controllers/UsersController.cs +++ b/LaDOSE.Src/LaDOSE.Api/Controllers/UsersController.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Security.Claims; using System.Text; using System.Threading.Tasks; -using LaDOSE.Api.Services; +using LaDOSE.Business.Interface; using LaDOSE.Entity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -32,24 +32,9 @@ namespace LaDOSE.Api.Controllers _configuration = configuration; } - [AllowAnonymous] - [HttpGet("test")] - public String Test() - { - return "DEAD"; - } - - - - [HttpGet("test2")] - public String Test2() - { - return "DEAD"; - } - [AllowAnonymous] - [HttpPost("authenticate")] + [HttpPost("auth")] public IActionResult Authenticate([FromBody]ApplicationUser userDto) { var user = _userService.Authenticate(userDto.Username, userDto.Password); @@ -82,25 +67,25 @@ namespace LaDOSE.Api.Controllers }); } - [AllowAnonymous] - [HttpPost("register")] - public IActionResult Register([FromBody]ApplicationUser userDto) - { - // map dto to entity + //[AllowAnonymous] + //[HttpPost("register")] + //public IActionResult Register([FromBody]ApplicationUser userDto) + //{ + // // map dto to entity - try - { - // save - _userService.Create(userDto, userDto.Password); - return Ok(); - } - catch (Exception ex) - { - // return error message if there was an exception - return BadRequest(new { message = ex.Message }); - } - } + // try + // { + // // save + // _userService.Create(userDto, userDto.Password); + // return Ok(); + // } + // catch (Exception ex) + // { + // // return error message if there was an exception + // return BadRequest(new { message = ex.Message }); + // } + //} } diff --git a/LaDOSE.Src/LaDOSE.Api/LaDOSE.Api.csproj b/LaDOSE.Src/LaDOSE.Api/LaDOSE.Api.csproj index bb27108..26c785f 100644 --- a/LaDOSE.Src/LaDOSE.Api/LaDOSE.Api.csproj +++ b/LaDOSE.Src/LaDOSE.Api/LaDOSE.Api.csproj @@ -5,6 +5,7 @@ + @@ -15,6 +16,7 @@ + diff --git a/LaDOSE.Src/LaDOSE.Api/Startup.cs b/LaDOSE.Src/LaDOSE.Api/Startup.cs index 938c4a0..a10e57d 100644 --- a/LaDOSE.Src/LaDOSE.Api/Startup.cs +++ b/LaDOSE.Src/LaDOSE.Api/Startup.cs @@ -3,9 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using LaDOSE.Api.Context; -using LaDOSE.Api.Services; +using LaDOSE.Business.Interface; +using LaDOSE.Business.Service; using LaDOSE.Entity; +using LaDOSE.Entity.Context; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -18,7 +19,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -using Pomelo.EntityFrameworkCore.MySql; +using Pomelo.EntityFrameworkCore.MySql; using Pomelo.EntityFrameworkCore.MySql.Infrastructure; namespace LaDOSE.Api @@ -45,6 +46,7 @@ namespace LaDOSE.Api options => options.UseMySql($"Server={MySqlServer};Database={MySqlDatabase};User={MySqlUser};Password={MySqlPassword};", // replace with your Connection String mysqlOptions => { + mysqlOptions.ServerVersion(new Version(10, 1, 16), ServerType.MariaDb); // replace with your Server Version and Type } )); diff --git a/LaDOSE.Src/LaDOSE.Api/Context/LaDOSEDbContext.cs b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs similarity index 76% rename from LaDOSE.Src/LaDOSE.Api/Context/LaDOSEDbContext.cs rename to LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs index 2d534c3..17b0d6f 100644 --- a/LaDOSE.Src/LaDOSE.Api/Context/LaDOSEDbContext.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs @@ -1,13 +1,12 @@ - -using System; -using LaDOSE.Entity; -using Microsoft.EntityFrameworkCore; -namespace LaDOSE.Api.Context +using Microsoft.EntityFrameworkCore; + +namespace LaDOSE.Entity.Context { public class LaDOSEDbContext : DbContext { public DbSet Game { get; set; } public DbSet ApplicationUser { get; set; } + public DbSet Season { get; set; } public LaDOSEDbContext(DbContextOptions options) : base(options) { @@ -18,4 +17,6 @@ namespace LaDOSE.Api.Context base.OnModelCreating(modelBuilder); } } + + } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/LaDOSE.Entity.csproj b/LaDOSE.Src/LaDOSE.Entity/LaDOSE.Entity.csproj index 5766db6..932ef78 100644 --- a/LaDOSE.Src/LaDOSE.Entity/LaDOSE.Entity.csproj +++ b/LaDOSE.Src/LaDOSE.Entity/LaDOSE.Entity.csproj @@ -4,4 +4,8 @@ netcoreapp2.0 + + + + diff --git a/LaDOSE.Src/LaDOSE.Entity/Season.cs b/LaDOSE.Src/LaDOSE.Entity/Season.cs new file mode 100644 index 0000000..6604359 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/Season.cs @@ -0,0 +1,15 @@ +using System; + +namespace LaDOSE.Entity +{ + public class Season + { + public int Id { get; set; } + public string Name { get; set; } + + public DateTime StartDate { get; set; } + public DateTime EndDate { get; set; } + + + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/IUserService.cs b/LaDOSE.Src/LaDOSE.Service/Interface/IUserService.cs new file mode 100644 index 0000000..6e501b4 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Service/Interface/IUserService.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using LaDOSE.Entity; + +namespace LaDOSE.Business.Interface +{ + public interface IUserService + { + ApplicationUser Authenticate(string username, string password); + IEnumerable GetAll(); + ApplicationUser GetById(int id); + ApplicationUser Create(ApplicationUser user, string password); + void Update(ApplicationUser user, string password = null); + void Delete(int id); + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/LaDOSE.Business.csproj b/LaDOSE.Src/LaDOSE.Service/LaDOSE.Business.csproj new file mode 100644 index 0000000..10f635d --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Service/LaDOSE.Business.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp2.0 + LaDOSE.Business + LaDOSE.Business + + + + + + + diff --git a/LaDOSE.Src/LaDOSE.Api/Services/UserService.cs b/LaDOSE.Src/LaDOSE.Service/Service/UserService.cs similarity index 92% rename from LaDOSE.Src/LaDOSE.Api/Services/UserService.cs rename to LaDOSE.Src/LaDOSE.Service/Service/UserService.cs index 14b4e03..4088d47 100644 --- a/LaDOSE.Src/LaDOSE.Api/Services/UserService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/UserService.cs @@ -1,21 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using LaDOSE.Api.Context; +using LaDOSE.Business.Interface; using LaDOSE.Entity; +using LaDOSE.Entity.Context; -namespace LaDOSE.Api.Services +namespace LaDOSE.Business.Service { - public interface IUserService - { - ApplicationUser Authenticate(string username, string password); - IEnumerable GetAll(); - ApplicationUser GetById(int id); - ApplicationUser Create(ApplicationUser user, string password); - void Update(ApplicationUser user, string password = null); - void Delete(int id); - } - public class UserService : IUserService { private LaDOSEDbContext _context; diff --git a/LaDOSE.Src/LaDOSE.sln b/LaDOSE.Src/LaDOSE.sln index 9f51940..3f54d7b 100644 --- a/LaDOSE.Src/LaDOSE.sln +++ b/LaDOSE.Src/LaDOSE.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Api", "LaDOSE.Api\La EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Entity", "LaDOSE.Entity\LaDOSE.Entity.csproj", "{B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Business", "LaDOSE.Service\LaDOSE.Business.csproj", "{952DE665-70B5-492B-BE91-D0111E3BD907}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU {B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU {B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}.Release|Any CPU.Build.0 = Release|Any CPU + {952DE665-70B5-492B-BE91-D0111E3BD907}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {952DE665-70B5-492B-BE91-D0111E3BD907}.Debug|Any CPU.Build.0 = Debug|Any CPU + {952DE665-70B5-492B-BE91-D0111E3BD907}.Release|Any CPU.ActiveCfg = Release|Any CPU + {952DE665-70B5-492B-BE91-D0111E3BD907}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE