You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
using Extraction_Donnees.Extraction_EXECL;
|
|
using Interface;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Modele.Classe;
|
|
|
|
namespace Api.Controllers
|
|
{
|
|
[Route("[controller]")]
|
|
[ApiController]
|
|
public class File : Controller
|
|
{
|
|
private readonly IApi data;
|
|
|
|
public File(IApi manager)
|
|
{
|
|
this.data = manager;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> PostExecl(IFormFile file, string pseudoPilote,string Email ,string password,string nameSession, string nameCircuit, string typeSession)
|
|
{
|
|
Pilote pilote = await data.CheckPilote(Email, password);
|
|
if (pilote == null)
|
|
{
|
|
return BadRequest();
|
|
}
|
|
|
|
|
|
if ( file == null || file.Length == 0)
|
|
{
|
|
return BadRequest("File vide");
|
|
}
|
|
Session session;
|
|
try
|
|
{
|
|
session = await Excel.ReadExcel(file);
|
|
await data.AddSession(session,pseudoPilote, nameCircuit, nameSession,typeSession);
|
|
}
|
|
catch(Exception e) {
|
|
return BadRequest(e.Message);
|
|
}
|
|
|
|
return Ok(session.Tours[0].Points[0]);
|
|
}
|
|
}
|
|
}
|