mycorerepository/MyCore/Controllers/ValuesController.cs
Thomas Fransolet 8ec099f688 OddsService WIP
2020-01-13 20:22:06 +01:00

89 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MQTTnet;
using MQTTnet.Client;
using MQTTnet.Server;
using MyCore.Models;
using MyCore.Services;
using static MyCore.Services.OddService;
namespace MyCore.Controllers
{
[Authorize(Roles = "Admin")]
[Route("api/test")]
[ApiController]
public class ValuesController : ControllerBase
{
private OddService oddService = new OddService(OddService.RegionOdd.UK);
// GET api/values
/// <summary>
/// It's a test ! :)
/// </summary>
/// <param name="id">id test</param>
[AllowAnonymous]
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
WidgetWeather widgetWeather = new WidgetWeather();
try
{
League league = new League("BE");
oddService.GetOddsForLeague(league).ContinueWith(res =>
{
if (res.Status == TaskStatus.RanToCompletion)
{
var test = res.Result;
}
else
{
}
}); ;
}
catch (Exception e)
{
Console.WriteLine(e);
}
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
// For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
// For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
// For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803
}
}
}