diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..d6051ba --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "3.1.5", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/BDAccess/APIAccess.cs b/BDAccess/APIAccess.cs new file mode 100644 index 0000000..ffd6ceb --- /dev/null +++ b/BDAccess/APIAccess.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Runtime.CompilerServices; +using System.Text.Json; +using System.Threading.Tasks; + +namespace EPAServeur.BDAccess +{ + public class APIAccess + { + private static APIAccess instance = null; + private string serveur = "http://localhost:3000"; + + private APIAccess() + { + + } + + public static APIAccess getInstance() + { + return instance; + } + + public static List requestAPI(string query) + { + if (instance == null) + { + instance = new APIAccess(); + } + + List result = new List(); + WebClient client = new WebClient(); + result = JsonSerializer.Deserialize>(client.DownloadString(instance.serveur+query)); + + return result; + } + } +} diff --git a/BDAccess/BDaccess.cs b/BDAccess/BDaccess.cs new file mode 100644 index 0000000..9cc2349 --- /dev/null +++ b/BDAccess/BDaccess.cs @@ -0,0 +1,47 @@ +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace EPAServeur.BDAccess +{ + public class BDAccess + { + private static BDAccess instance = null; + private MySqlConnection connection; + + private BDAccess() + { + MySqlConnectionStringBuilder infoConnection = new MySqlConnectionStringBuilder() + { + Server = "localhost", + Port = 3306, + Database = "evaluationprofessionelle", + UserID = "dev", + Password = "dev" + }; + this.connection = new MySqlConnection(infoConnection.ConnectionString); + } + + public static BDAccess getInstance() + { + return instance; + } + + public static MySqlDataReader executeQuery(string query) + { + if (instance == null) + { + instance = new BDAccess(); + } + + MySqlCommand command = new MySqlCommand(query, instance.connection); + command.Connection.Open(); + + return command.ExecuteReader(); + } + + } +} diff --git a/Controllers/CollaborateurController/CollaborateurControlleur.cs b/Controllers/CollaborateurController/CollaborateurControlleur.cs new file mode 100644 index 0000000..2a9e03b --- /dev/null +++ b/Controllers/CollaborateurController/CollaborateurControlleur.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using EPAServeur.BDAccess; +using EPAServeur.CollaborateurModele.Collaborateur; +using Microsoft.AspNetCore.Mvc; +using MySql.Data.MySqlClient; + +namespace EPAServeur.Controllers.CollaborateurController +{ + [Route("api/")] + [ApiController] + public class CollaborateurControlleur : ControllerBase + { + [HttpGet("collaborateurs")] + public IEnumerable Get() + { + List liste = APIAccess.requestAPI("/personne"); + return liste; + } + } +} diff --git a/Controllers/EpController/EPController.cs b/Controllers/EpController/EPController.cs new file mode 100644 index 0000000..cbc31b4 --- /dev/null +++ b/Controllers/EpController/EPController.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace EPAServeur.Controllers.EpController +{ + [Route("api/[controller]")] + [ApiController] + public class EPController : ControllerBase + { + } +} diff --git a/Controllers/FormationController/FormationController.cs b/Controllers/FormationController/FormationController.cs new file mode 100644 index 0000000..9861d74 --- /dev/null +++ b/Controllers/FormationController/FormationController.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace EPAServeur.Controllers.FormationController +{ + [Route("api/[controller]")] + [ApiController] + public class FormationController : ControllerBase + { + } +} diff --git a/Controllers/ProfilController/ProfilController.cs b/Controllers/ProfilController/ProfilController.cs new file mode 100644 index 0000000..71c728b --- /dev/null +++ b/Controllers/ProfilController/ProfilController.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace EPAServeur.Controllers.ProfilController +{ + [Route("api/[controller]")] + [ApiController] + public class ProfilController : ControllerBase + { + } +} diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs deleted file mode 100644 index b83c358..0000000 --- a/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; - -namespace EPAServeur.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet] - public IEnumerable Get() - { - var rng = new Random(); - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateTime.Now.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/EPAServeur.csproj b/EPAServeur.csproj index d12c450..cf0fa15 100644 --- a/EPAServeur.csproj +++ b/EPAServeur.csproj @@ -4,5 +4,9 @@ netcoreapp3.1 + + + + diff --git a/Modele/CollaborateurModele/Collaborateur.cs b/Modele/CollaborateurModele/Collaborateur.cs new file mode 100644 index 0000000..20514f0 --- /dev/null +++ b/Modele/CollaborateurModele/Collaborateur.cs @@ -0,0 +1,29 @@ +using Org.BouncyCastle.Crypto.Digests; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EPAServeur.CollaborateurModele.Collaborateur +{ + public class Collaborateur + { + public int id { get; set; } + public string nom { get; set; } + public string prenom { get; set; } + public string mail { get; set; } + + public Collaborateur() + { + + } + + public Collaborateur(int id, string nom, string prenom, string mail) + { + this.id = id; + this.nom = nom; + this.prenom = prenom; + this.mail = mail; + } + } +} diff --git a/Modele/EpModele/EP.cs b/Modele/EpModele/EP.cs new file mode 100644 index 0000000..41b14d8 --- /dev/null +++ b/Modele/EpModele/EP.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EPAServeur.Modele.EpModele +{ + public class EP + { + } +} diff --git a/Modele/FormationModele/Formation.cs b/Modele/FormationModele/Formation.cs new file mode 100644 index 0000000..63530b1 --- /dev/null +++ b/Modele/FormationModele/Formation.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EPAServeur.Modele.FormationModele +{ + public class Formation + { + } +} diff --git a/Modele/ProfilModele/Profil.cs b/Modele/ProfilModele/Profil.cs new file mode 100644 index 0000000..da6d864 --- /dev/null +++ b/Modele/ProfilModele/Profil.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EPAServeur.Modele.ProfilModele +{ + public class Profil + { + } +} diff --git a/Program.cs b/Program.cs index 5025e11..8733b52 100644 --- a/Program.cs +++ b/Program.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using MySql.Data.MySqlClient; namespace EPAServeur { @@ -13,7 +15,8 @@ namespace EPAServeur { public static void Main(string[] args) { - CreateHostBuilder(args).Build().Run(); + CreateHostBuilder(args).Build().Run(); + } public static IHostBuilder CreateHostBuilder(string[] args) => diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 0613e9f..ba3aba4 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -12,16 +12,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "weatherforecast", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "EPAServeur": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "weatherforecast", - "applicationUrl": "https://localhost:5001;http://localhost:5000", + "launchUrl": "api/collaborateurs", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/WeatherForecast.cs b/WeatherForecast.cs deleted file mode 100644 index 60c32b9..0000000 --- a/WeatherForecast.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace EPAServeur -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string Summary { get; set; } - } -}