Merge pull request #2 from darkstack/MigrationDotNetCore3

Migration DotNetCore
This commit is contained in:
2020-09-26 21:03:41 +02:00
committed by GitHub
14 changed files with 59 additions and 40 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper;
using LaDOSE.Business.Interface; using LaDOSE.Business.Interface;
using LaDOSE.DTO; using LaDOSE.DTO;
using LaDOSE.Entity; using LaDOSE.Entity;
@@ -16,7 +17,7 @@ namespace LaDOSE.Api.Controllers
[Produces("application/json")] [Produces("application/json")]
public class GameController : GenericControllerDTO<IGameService, Game, GameDTO> public class GameController : GenericControllerDTO<IGameService, Game, GameDTO>
{ {
public GameController(IGameService service) : base(service) public GameController(IMapper mapper,IGameService service) : base(mapper,service)
{ {
} }
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using AutoMapper;
using LaDOSE.Business.Interface; using LaDOSE.Business.Interface;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -8,30 +9,32 @@ namespace LaDOSE.Api.Controllers
{ {
public class GenericControllerDTO<T, TU, D> : Controller where TU : Entity.Context.Entity where T : IBaseService<TU> public class GenericControllerDTO<T, TU, D> : Controller where TU : Entity.Context.Entity where T : IBaseService<TU>
{ {
protected IMapper _mapper;
protected T _service; protected T _service;
public GenericControllerDTO(T service) public GenericControllerDTO(IMapper mapper, T service)
{ {
_mapper = mapper;
_service = service; _service = service;
} }
[HttpPost] [HttpPost]
public D Post([FromBody]D dto) public D Post([FromBody]D dto)
{ {
TU entity = AutoMapper.Mapper.Map<TU>(dto); TU entity = _mapper.Map<TU>(dto);
return AutoMapper.Mapper.Map<D>(_service.AddOrUpdate(entity)); return _mapper.Map<D>(_service.AddOrUpdate(entity));
} }
[HttpGet] [HttpGet]
public List<D> Get() public List<D> Get()
{ {
return AutoMapper.Mapper.Map<List<D>>(_service.GetAll().ToList()); return _mapper.Map<List<D>>(_service.GetAll().ToList());
} }
[HttpGet("{id}")] [HttpGet("{id}")]
public D Get(int id) public D Get(int id)
{ {
return AutoMapper.Mapper.Map<D>(_service.GetById(id)); return _mapper.Map<D>(_service.GetById(id));
} }
[HttpDelete("{id}")] [HttpDelete("{id}")]

View File

@@ -1,4 +1,5 @@
using LaDOSE.Business.Interface; using AutoMapper;
using LaDOSE.Business.Interface;
using LaDOSE.DTO; using LaDOSE.DTO;
using LaDOSE.Entity; using LaDOSE.Entity;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@@ -11,7 +12,7 @@ namespace LaDOSE.Api.Controllers
[Produces("application/json")] [Produces("application/json")]
public class TodoController : GenericControllerDTO<ITodoService, Todo, TodoDTO> public class TodoController : GenericControllerDTO<ITodoService, Todo, TodoDTO>
{ {
public TodoController(ITodoService service) : base(service) public TodoController(IMapper mapper,ITodoService service) : base(mapper,service)
{ {
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper;
using LaDOSE.Business.Interface; using LaDOSE.Business.Interface;
using LaDOSE.DTO; using LaDOSE.DTO;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@@ -15,10 +16,13 @@ namespace LaDOSE.Api.Controllers
{ {
private ITournamentService _service; private ITournamentService _service;
// GET
public TournamentController(ITournamentService service)
{
private IMapper _mapper;
// GET
public TournamentController(IMapper mapper,ITournamentService service)
{
_mapper = mapper;
_service = service; _service = service;
} }
//This may be a get , but i dont know what the RFC State for Get request with Body //This may be a get , but i dont know what the RFC State for Get request with Body
@@ -30,7 +34,7 @@ namespace LaDOSE.Api.Controllers
if (dto.To.HasValue | dto.From.HasValue) if (dto.To.HasValue | dto.From.HasValue)
{ {
var tournaments = await _service.GetTournaments(dto.From, dto.To); var tournaments = await _service.GetTournaments(dto.From, dto.To);
return AutoMapper.Mapper.Map<List<TournamentDTO>>(tournaments); return _mapper.Map<List<TournamentDTO>>(tournaments);
} }
@@ -47,7 +51,7 @@ namespace LaDOSE.Api.Controllers
} }
var tournamentsResult = await _service.GetTournamentsResult(ids); var tournamentsResult = await _service.GetTournamentsResult(ids);
return AutoMapper.Mapper.Map<TournamentsResultDTO>(tournamentsResult); return _mapper.Map<TournamentsResultDTO>(tournamentsResult);
} }
} }

View File

@@ -13,13 +13,15 @@ namespace LaDOSE.Api.Controllers
[Route("api/[controller]")] [Route("api/[controller]")]
public class WordPressController : Controller public class WordPressController : Controller
{ {
private readonly IMapper _mapper;
public IGameService GameService { get; } public IGameService GameService { get; }
private IWordPressService _service; private IWordPressService _service;
// GET // GET
public WordPressController(IWordPressService service, IGameService gameService) public WordPressController(IMapper mapper,IWordPressService service, IGameService gameService)
{ {
_mapper = mapper;
GameService = gameService; GameService = gameService;
_service = service; _service = service;
} }
@@ -38,7 +40,7 @@ namespace LaDOSE.Api.Controllers
} }
} }
return Mapper.Map<List<WPEventDTO>>(wpEvents); return _mapper.Map<List<WPEventDTO>>(wpEvents);
} }
@@ -54,21 +56,21 @@ namespace LaDOSE.Api.Controllers
wpEventWpBooking.WPUser.WPBookings = null; wpEventWpBooking.WPUser.WPBookings = null;
} }
return Mapper.Map<WPEventDTO>(wpEvents); return _mapper.Map<WPEventDTO>(wpEvents);
} }
[HttpGet("GetUsers/{wpEventId}/{gameId}")] [HttpGet("GetUsers/{wpEventId}/{gameId}")]
public List<WPUserDTO> GetUsers(int wpEventId, int gameId) public List<WPUserDTO> GetUsers(int wpEventId, int gameId)
{ {
var game = GameService.GetById(gameId); var game = GameService.GetById(gameId);
return Mapper.Map<List<WPUserDTO>>(_service.GetBooking(wpEventId, game)); return _mapper.Map<List<WPUserDTO>>(_service.GetBooking(wpEventId, game));
} }
[HttpGet("GetUsersOptions/{wpEventId}/{gameId}")] [HttpGet("GetUsersOptions/{wpEventId}/{gameId}")]
public List<WPUserDTO> GetUsersOptions(int wpEventId, int gameId) public List<WPUserDTO> GetUsersOptions(int wpEventId, int gameId)
{ {
var game = GameService.GetById(gameId); var game = GameService.GetById(gameId);
return Mapper.Map<List<WPUserDTO>>(_service.GetBookingOptions(wpEventId, game)); return _mapper.Map<List<WPUserDTO>>(_service.GetBookingOptions(wpEventId, game));
} }

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
@@ -10,11 +10,13 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" /> <PackageReference Include="AutoMapper" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -7,7 +7,7 @@ using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal; //using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace LaDOSE.Api namespace LaDOSE.Api

View File

@@ -63,7 +63,7 @@ namespace LaDOSE.Api
} }
services.AddCors(); services.AddCors();
services.AddMvc().AddJsonOptions(x => services.AddMvc().AddNewtonsoftJson(x =>
{ {
x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
x.SerializerSettings.MaxDepth= 4; x.SerializerSettings.MaxDepth= 4;
@@ -114,7 +114,7 @@ namespace LaDOSE.Api
// configure DI for application services // configure DI for application services
AddDIConfig(services); AddDIConfig(services);
Mapper.Initialize(cfg => var mapperConfig = new MapperConfiguration(cfg =>
{ {
cfg.CreateMap<WPUser, LaDOSE.DTO.WPUserDTO>(); cfg.CreateMap<WPUser, LaDOSE.DTO.WPUserDTO>();
cfg.CreateMap<WPUser, LaDOSE.DTO.WPUserDTO>(); cfg.CreateMap<WPUser, LaDOSE.DTO.WPUserDTO>();
@@ -131,6 +131,9 @@ namespace LaDOSE.Api
cfg.CreateMapTwoWay<Todo, LaDOSE.DTO.TodoDTO>(); cfg.CreateMapTwoWay<Todo, LaDOSE.DTO.TodoDTO>();
}); });
IMapper mapper = mapperConfig.CreateMapper();
services.AddSingleton(mapper);
} }
private void AddDIConfig(IServiceCollection services) private void AddDIConfig(IServiceCollection services)
@@ -151,8 +154,8 @@ namespace LaDOSE.Api
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole(Configuration.GetSection("Logging")); //loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug(); //loggerFactory.AddDebug();
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
@@ -160,14 +163,17 @@ namespace LaDOSE.Api
} }
app.UseCors(x => x app.UseCors(x => x
.AllowAnyOrigin() //.AllowAnyOrigin()
.AllowAnyMethod() .AllowAnyMethod()
.AllowAnyHeader() .AllowAnyHeader()
.SetIsOriginAllowed(origin => true)
.AllowCredentials()); .AllowCredentials());
//app.UseHttpsRedirection(); //app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication(); app.UseAuthentication();
app.UseMvc(); app.UseAuthorization();
app.UseEndpoints(x => x.MapControllers());
} }
} }
} }

View File

@@ -81,8 +81,8 @@
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL"> <Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath> <HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="RestSharp, Version=106.6.9.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=106.11.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.6.9\lib\net452\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />

View File

@@ -6,6 +6,6 @@
<package id="cef.redist.x86" version="73.1.13" targetFramework="net461" /> <package id="cef.redist.x86" version="73.1.13" targetFramework="net461" />
<package id="CefSharp.Common" version="73.1.130" targetFramework="net461" /> <package id="CefSharp.Common" version="73.1.130" targetFramework="net461" />
<package id="CefSharp.Wpf" version="73.1.130" targetFramework="net461" /> <package id="CefSharp.Wpf" version="73.1.130" targetFramework="net461" />
<package id="RestSharp" version="106.6.9" targetFramework="net461" /> <package id="RestSharp" version="106.11.4" targetFramework="net461" />
<package id="WPFThemes.DarkBlend" version="1.0.8" targetFramework="net461" /> <package id="WPFThemes.DarkBlend" version="1.0.8" targetFramework="net461" />
</packages> </packages>

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
@@ -10,8 +10,8 @@
<PackageReference Include="DSharpPlus" Version="3.2.3" /> <PackageReference Include="DSharpPlus" Version="3.2.3" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="3.2.3" /> <PackageReference Include="DSharpPlus.CommandsNext" Version="3.2.3" />
<PackageReference Include="DSharpPlus.Interactivity" Version="3.2.3" /> <PackageReference Include="DSharpPlus.Interactivity" Version="3.2.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="RestSharp" Version="106.6.9" /> <PackageReference Include="RestSharp" Version="106.11.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>LaDOSE.Business</AssemblyName> <AssemblyName>LaDOSE.Business</AssemblyName>
<RootNamespace>LaDOSE.Business</RootNamespace> <RootNamespace>LaDOSE.Business</RootNamespace>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>