Challonge Provider can create tournament

This commit is contained in:
2018-10-07 15:15:11 +02:00
parent 9a9d4c7053
commit 681deda3d2
17 changed files with 245 additions and 18 deletions

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LaDOSE.Business.Interface;
using LaDOSE.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace LaDOSE.Api.Controllers
{
[Produces("application/json")]
[Route("api/[controller]")]
public class EventController : Controller
{
private IEventService _eventService;
public EventController(IEventService eventService)
{
_eventService = eventService;
}
[HttpPost]
public Event Post([FromBody]Event dto)
{
return _eventService.Create(dto);
}
[HttpGet("{id}")]
public Event Get(int id)
{
return _eventService.GetById(id);
}
[HttpGet("Generate/{dto}")]
public bool GenerateChallonge(int dto)
{
return _eventService.CreateChallonge(dto);
}
}
}

View File

@@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" />
</ItemGroup>

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LaDOSE.Business.Interface;
using LaDOSE.Business.Provider;
using LaDOSE.Business.Service;
using LaDOSE.Entity;
using LaDOSE.Entity.Context;
@@ -40,6 +41,7 @@ namespace LaDOSE.Api
var MySqlDatabase = this.Configuration["MySql:Database"];
var MySqlUser = this.Configuration["MySql:User"];
var MySqlPassword = this.Configuration["MySql:Password"];
services.AddCors();
services.AddMvc().AddJsonOptions(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
services.AddDbContextPool<LaDOSEDbContext>( // replace "YourDbContext" with the class name of your DbContext
@@ -86,11 +88,18 @@ namespace LaDOSE.Api
});
// configure DI for application services
AddDIConfig(services);
}
private void AddDIConfig(IServiceCollection services)
{
services.AddScoped<IUserService, UserService>();
services.AddScoped<IGameService, GameService>();
services.AddScoped<IEventService, EventService>();
services.AddTransient<IChallongeProvider>(p => new ChallongeProvider(this.Configuration["ApiKey:ChallongeApiKey"]));
}
// 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)

View File

@@ -14,6 +14,9 @@
"User": "User",
"Password": "Password"
},
"ApiKey": {
"ChallongeApiKey": "Challonge ApiKey"
},
"AllowedHosts": "*",
"Port": 5000,
"JWTTokenSecret": "here goes the custom Secret key for authnetication"