Ordering files

This commit is contained in:
2018-10-06 13:05:38 +02:00
parent f670cd78a8
commit d3cdc93c14
11 changed files with 89 additions and 55 deletions

View File

@@ -2,8 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using LaDOSE.Api.Context;
using LaDOSE.Entity; using LaDOSE.Entity;
using LaDOSE.Entity.Context;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

View File

@@ -5,7 +5,7 @@ using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using LaDOSE.Api.Services; using LaDOSE.Business.Interface;
using LaDOSE.Entity; using LaDOSE.Entity;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -32,24 +32,9 @@ namespace LaDOSE.Api.Controllers
_configuration = configuration; _configuration = configuration;
} }
[AllowAnonymous]
[HttpGet("test")]
public String Test()
{
return "DEAD";
}
[HttpGet("test2")]
public String Test2()
{
return "DEAD";
}
[AllowAnonymous] [AllowAnonymous]
[HttpPost("authenticate")] [HttpPost("auth")]
public IActionResult Authenticate([FromBody]ApplicationUser userDto) public IActionResult Authenticate([FromBody]ApplicationUser userDto)
{ {
var user = _userService.Authenticate(userDto.Username, userDto.Password); var user = _userService.Authenticate(userDto.Username, userDto.Password);
@@ -82,25 +67,25 @@ namespace LaDOSE.Api.Controllers
}); });
} }
[AllowAnonymous] //[AllowAnonymous]
[HttpPost("register")] //[HttpPost("register")]
public IActionResult Register([FromBody]ApplicationUser userDto) //public IActionResult Register([FromBody]ApplicationUser userDto)
{ //{
// map dto to entity // // map dto to entity
try // try
{ // {
// save // // save
_userService.Create(userDto, userDto.Password); // _userService.Create(userDto, userDto.Password);
return Ok(); // return Ok();
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
// return error message if there was an exception // // return error message if there was an exception
return BadRequest(new { message = ex.Message }); // return BadRequest(new { message = ex.Message });
} // }
} //}
} }

View File

@@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Services\" />
<Folder Include="wwwroot\" /> <Folder Include="wwwroot\" />
</ItemGroup> </ItemGroup>
@@ -15,6 +16,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LaDOSE.Entity\LaDOSE.Entity.csproj" /> <ProjectReference Include="..\LaDOSE.Entity\LaDOSE.Entity.csproj" />
<ProjectReference Include="..\LaDOSE.Service\LaDOSE.Business.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -3,9 +3,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using LaDOSE.Api.Context; using LaDOSE.Business.Interface;
using LaDOSE.Api.Services; using LaDOSE.Business.Service;
using LaDOSE.Entity; using LaDOSE.Entity;
using LaDOSE.Entity.Context;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@@ -45,6 +46,7 @@ namespace LaDOSE.Api
options => options.UseMySql($"Server={MySqlServer};Database={MySqlDatabase};User={MySqlUser};Password={MySqlPassword};", // replace with your Connection String options => options.UseMySql($"Server={MySqlServer};Database={MySqlDatabase};User={MySqlUser};Password={MySqlPassword};", // replace with your Connection String
mysqlOptions => mysqlOptions =>
{ {
mysqlOptions.ServerVersion(new Version(10, 1, 16), ServerType.MariaDb); // replace with your Server Version and Type mysqlOptions.ServerVersion(new Version(10, 1, 16), ServerType.MariaDb); // replace with your Server Version and Type
} }
)); ));

View File

@@ -1,13 +1,12 @@
 using Microsoft.EntityFrameworkCore;
using System;
using LaDOSE.Entity; namespace LaDOSE.Entity.Context
using Microsoft.EntityFrameworkCore;
namespace LaDOSE.Api.Context
{ {
public class LaDOSEDbContext : DbContext public class LaDOSEDbContext : DbContext
{ {
public DbSet<Game> Game { get; set; } public DbSet<Game> Game { get; set; }
public DbSet<ApplicationUser> ApplicationUser { get; set; } public DbSet<ApplicationUser> ApplicationUser { get; set; }
public DbSet<Season> Season { get; set; }
public LaDOSEDbContext(DbContextOptions options) : base(options) public LaDOSEDbContext(DbContextOptions options) : base(options)
{ {
@@ -18,4 +17,6 @@ namespace LaDOSE.Api.Context
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
} }
} }
} }

View File

@@ -4,4 +4,8 @@
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" />
</ItemGroup>
</Project> </Project>

View File

@@ -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; }
}
}

View File

@@ -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<ApplicationUser> GetAll();
ApplicationUser GetById(int id);
ApplicationUser Create(ApplicationUser user, string password);
void Update(ApplicationUser user, string password = null);
void Delete(int id);
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>LaDOSE.Business</AssemblyName>
<RootNamespace>LaDOSE.Business</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LaDOSE.Entity\LaDOSE.Entity.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,21 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using LaDOSE.Api.Context; using LaDOSE.Business.Interface;
using LaDOSE.Entity; 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<ApplicationUser> 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 public class UserService : IUserService
{ {
private LaDOSEDbContext _context; private LaDOSEDbContext _context;

View File

@@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Api", "LaDOSE.Api\La
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Entity", "LaDOSE.Entity\LaDOSE.Entity.csproj", "{B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Entity", "LaDOSE.Entity\LaDOSE.Entity.csproj", "{B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.Business", "LaDOSE.Service\LaDOSE.Business.csproj", "{952DE665-70B5-492B-BE91-D0111E3BD907}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{B32A4AD5-9A4B-4D12-AAD5-55541F170E2A}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE