parent
36da6f99c1
commit
7afe33c430
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1"/>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\API_DbDataManager\API_DbDataManager.csproj" />
|
||||||
|
<ProjectReference Include="..\API_Services\API_Services.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,6 @@
|
|||||||
|
@API_HostAddress = http://localhost:5052
|
||||||
|
|
||||||
|
GET {{API_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
@ -0,0 +1,64 @@
|
|||||||
|
using API_Services;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Model;
|
||||||
|
|
||||||
|
|
||||||
|
namespace API.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ArticleController : ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IArticleService _articleService;
|
||||||
|
|
||||||
|
public ArticleController(IArticleService articleService)
|
||||||
|
{
|
||||||
|
_articleService = articleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("/articles")]
|
||||||
|
public async Task<IActionResult> GetAllArticles()
|
||||||
|
{
|
||||||
|
var result = await _articleService.GetAllArticles();
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("/article/{id}")]
|
||||||
|
public async Task<Article?> GetArticleById(int id)
|
||||||
|
{
|
||||||
|
var result = await _articleService.GetArticleById(id);
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost("/article")]
|
||||||
|
public async Task<Article?> CreateArticle(long id, string title, string description, string author, string date, int lectureTime)
|
||||||
|
{
|
||||||
|
return await _articleService.CreateArticle(id, title, description, author, date, lectureTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("/article/{id}")]
|
||||||
|
public async Task<Article?> DeleteArticle(long id)
|
||||||
|
{
|
||||||
|
return await _articleService.DeleteArticle(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("/article/{id}")]
|
||||||
|
public async Task<bool> UpdateArticle(long id, Article? a)
|
||||||
|
{
|
||||||
|
return await _articleService.UpdateArticle(id, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using API_Services;
|
||||||
|
using Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace API.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class FormulaireController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IFormulaireService _form;
|
||||||
|
|
||||||
|
public FormulaireController(IFormulaireService iform)
|
||||||
|
{
|
||||||
|
this._form = iform;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("/forms/{id}")]
|
||||||
|
public Task<IEnumerable<Formulaire?>> GetAllForm()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public Task<Formulaire?> GetById(long id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Task<Formulaire?> CreateForm(Formulaire formulaire)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public Task<bool> DeleteForm(long id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public Task<bool> UpdateForm(long id, Formulaire formulaire)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using API_Services;
|
||||||
|
using DbContextLib;
|
||||||
|
using DbDataManager;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
|
|
||||||
|
builder.Services.AddDbContext<LibraryContext>();
|
||||||
|
builder.Services.AddScoped<IArticleService, DbManagerArticle>();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app.Run();
|
@ -0,0 +1,66 @@
|
|||||||
|
using API_Services;
|
||||||
|
using DbContextLib;
|
||||||
|
using Entities;
|
||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace DbDataManager;
|
||||||
|
|
||||||
|
public class DbManagerArticle : IArticleService
|
||||||
|
{
|
||||||
|
private readonly LibraryContext _context;
|
||||||
|
|
||||||
|
public DbManagerArticle(LibraryContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Article?> CreateArticle(long id, string title, string description, string author, string date, int lectureTime)
|
||||||
|
{
|
||||||
|
var entity = new ArticleEntity()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Title = title,
|
||||||
|
Description = description,
|
||||||
|
Author = author,
|
||||||
|
DatePublished = date,
|
||||||
|
LectureTime = lectureTime,
|
||||||
|
};
|
||||||
|
_context.ArticleSet.Add(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return entity.ToModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Article?> DeleteArticle(long id)
|
||||||
|
{
|
||||||
|
var entity = _context.ArticleSet.FirstOrDefault(a => a.Id == id);
|
||||||
|
if (entity == null) return null;
|
||||||
|
_context.ArticleSet.Remove(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return entity.ToModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateArticle(long id, Article? a)
|
||||||
|
{
|
||||||
|
var entity = _context.ArticleSet.FirstOrDefault(a => a.Id == id);
|
||||||
|
if (entity == null) return false;
|
||||||
|
entity.Title = a.Title;
|
||||||
|
entity.Description = a.Description;
|
||||||
|
entity.Author = a.Author;
|
||||||
|
entity.DatePublished = a.DatePublished;
|
||||||
|
entity.LectureTime = a.LectureTime;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<Article?> GetArticleById(int id)
|
||||||
|
{
|
||||||
|
var entity = _context.ArticleSet.FirstOrDefault(a => a.Id == id);
|
||||||
|
return Task.FromResult(entity.ToModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Article?>> GetAllArticles()
|
||||||
|
{
|
||||||
|
return await Task.FromResult(_context.ArticleSet.Select(a => a.ToModel()).AsEnumerable());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
using API_Services;
|
||||||
|
using DbContextLib;
|
||||||
|
using Entities;
|
||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace DbDataManager;
|
||||||
|
|
||||||
|
public class DbManagerFormulaire(LibraryContext _context) : IFormulaireService
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<Formulaire?>> GetAllForm()
|
||||||
|
{
|
||||||
|
return await Task.FromResult(_context.FormSet.Select(f => f.ToModel()).AsEnumerable());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Formulaire?> GetById(long id)
|
||||||
|
{
|
||||||
|
var entity = _context.FormSet.FirstOrDefault(f => f.Id == id);
|
||||||
|
if (entity != null) return await Task.FromResult(entity.ToModel());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Formulaire?> CreateForm(Formulaire formulaire)
|
||||||
|
{
|
||||||
|
var entity = new FormEntity()
|
||||||
|
{
|
||||||
|
Id = formulaire.Id,
|
||||||
|
Pseudo = formulaire.Pseudo,
|
||||||
|
Theme = formulaire.Theme,
|
||||||
|
DatePublication = formulaire.Date
|
||||||
|
};
|
||||||
|
|
||||||
|
_context.FormSet.Add(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return entity.ToModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> DeleteForm(long id)
|
||||||
|
{
|
||||||
|
var entity = _context.FormSet.FirstOrDefault(f => f.Id == id);
|
||||||
|
if (entity == null) return false;
|
||||||
|
_context.FormSet.Remove(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateForm(long id, Formulaire formulaire)
|
||||||
|
{
|
||||||
|
var entity = _context.FormSet.FirstOrDefault(f => f.Id == id);
|
||||||
|
if (entity == null) return false;
|
||||||
|
entity.Pseudo = formulaire.Pseudo;
|
||||||
|
entity.Theme = formulaire.Theme;
|
||||||
|
entity.DatePublication = formulaire.Date;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
using API_Services;
|
||||||
|
using DbContextLib;
|
||||||
|
using Entities;
|
||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace DbDataManager;
|
||||||
|
|
||||||
|
public class DbManagerUser(LibraryContext _context): IUserService
|
||||||
|
{
|
||||||
|
public async Task<bool> Create(User user)
|
||||||
|
{
|
||||||
|
var entity = new UserEntity()
|
||||||
|
{
|
||||||
|
Pseudo = user.Pseudo,
|
||||||
|
Prenom = user.Prenom,
|
||||||
|
Nom = user.Nom,
|
||||||
|
Mdp = user.Mdp,
|
||||||
|
Mail = user.Mail,
|
||||||
|
Role = user.Role
|
||||||
|
};
|
||||||
|
_context.UserSet.Add(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Update(User user)
|
||||||
|
{
|
||||||
|
var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == user.Pseudo);
|
||||||
|
if (entity == null) return false;
|
||||||
|
entity.Mdp = user.Mdp;
|
||||||
|
entity.Mail = user.Mail;
|
||||||
|
entity.Role = user.Role;
|
||||||
|
entity.Prenom = user.Prenom;
|
||||||
|
entity.Nom = user.Nom;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Delete(string pseudo)
|
||||||
|
{
|
||||||
|
var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == pseudo);
|
||||||
|
if (entity == null) return await Task.FromResult(false);
|
||||||
|
_context.UserSet.Remove(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<User?> GetByPseudo(string pseudo)
|
||||||
|
{
|
||||||
|
var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == pseudo);
|
||||||
|
return await Task.FromResult(entity.ToModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<User?>> GetAll()
|
||||||
|
{
|
||||||
|
return await Task.FromResult(_context.UserSet.Select(u => u.ToModel()).AsEnumerable());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using Entities;
|
||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace DbDataManager;
|
||||||
|
|
||||||
|
public static class Extensions
|
||||||
|
{
|
||||||
|
public static ArticleEntity ToEntity(this Article article)
|
||||||
|
=> new ArticleEntity
|
||||||
|
{
|
||||||
|
Id = article.Id, Author = article.Author, Description = article.Description, Title = article.Title,
|
||||||
|
DatePublished = article.DatePublished, LectureTime = article.LectureTime
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Article ToModel(this ArticleEntity article)
|
||||||
|
=> new Article
|
||||||
|
{
|
||||||
|
Id = article.Id, Author = article.Author, Description = article.Description, Title = article.Title,
|
||||||
|
DatePublished = article.DatePublished, LectureTime = article.LectureTime
|
||||||
|
};
|
||||||
|
|
||||||
|
public static UserEntity ToEntity(this User user)
|
||||||
|
=> new UserEntity{ Pseudo = user.Pseudo, Mdp = user.Mdp, Prenom = user.Prenom, Nom = user.Nom, Mail = user.Mail, Role = user.Role};
|
||||||
|
|
||||||
|
public static User ToModel(this UserEntity user)
|
||||||
|
=> new User{ Pseudo = user.Pseudo, Mdp = user.Mdp, Prenom = user.Prenom, Nom = user.Nom, Mail = user.Mail, Role = user.Role};
|
||||||
|
|
||||||
|
public static FormEntity ToEntity(this Formulaire form)
|
||||||
|
=> new FormEntity{ Id = form.Id, Pseudo = form.Pseudo, Theme = form.Theme, Link = form.Lien};
|
||||||
|
|
||||||
|
public static Formulaire ToModel(this FormEntity form)
|
||||||
|
=> new Formulaire{ Id = form.Id, Pseudo = form.Pseudo, Theme = form.Theme, Lien = form.Link};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
@ -1,68 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Web_API.Model;
|
|
||||||
using API_Services;
|
|
||||||
|
|
||||||
namespace Web_API.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class ArticleController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IArticleService _as;
|
|
||||||
private Mapper.Mapper map = new Mapper.Mapper();
|
|
||||||
|
|
||||||
public ArticleController(IArticleService articleService)
|
|
||||||
{
|
|
||||||
this._as = articleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("Articles")]
|
|
||||||
|
|
||||||
public async Task<IActionResult> GetAllArticle()
|
|
||||||
{
|
|
||||||
return Ok(await _as.GetAllArticles());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public async Task<IActionResult> GetArticle(int id)
|
|
||||||
{
|
|
||||||
var article = await _as.GetById(id);
|
|
||||||
if (article == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
return Ok(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<ActionResult<Article>> PostArticle(ArticleDTO article)
|
|
||||||
{
|
|
||||||
var newArticle = await _as.Create(article);
|
|
||||||
if (newArticle == null) return BadRequest();
|
|
||||||
var newArticleEnt = map.ArtDTOToEntity(article);
|
|
||||||
return CreatedAtAction(nameof(GetArticle), new { id = newArticle.Id}, newArticleEnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
public async Task<ActionResult<Article>> PutArticle(long id , [FromBody]ArticleDTO article)
|
|
||||||
{
|
|
||||||
var check = await _as.Update(id,article);
|
|
||||||
if (!check) return NotFound();
|
|
||||||
var articleEnt = map.ArtDTOToEntity(article);
|
|
||||||
return articleEnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
public async Task<ActionResult<Article>> DeleteArticle(long id)
|
|
||||||
{
|
|
||||||
var articleDeleted = await _as.Delete(id);
|
|
||||||
if (articleDeleted == null)return NotFound();
|
|
||||||
articleDeleted = map.ArtEntityToDTO(articleDeleted);
|
|
||||||
return Ok(articleDeleted);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Web_API.Model;
|
|
||||||
using API_Services;
|
|
||||||
|
|
||||||
namespace Web_API.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class FormulaireController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IFormulaireService _form;
|
|
||||||
private Mapper.Mapper map = new Mapper.Mapper();
|
|
||||||
|
|
||||||
public FormulaireController(IFormulaireService iform)
|
|
||||||
{
|
|
||||||
this._form = iform;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<List<Formulaire>> GetAllForm()
|
|
||||||
{
|
|
||||||
var AllForms = await _form.GetAllForm();
|
|
||||||
return AllForms;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
using Entities;
|
|
||||||
using Web_API.Model;
|
|
||||||
|
|
||||||
namespace Web_API.Mapper;
|
|
||||||
|
|
||||||
public class Mapper
|
|
||||||
{
|
|
||||||
public ArticleDTO ArtEntityToDTO(ArticleEntity a)
|
|
||||||
{
|
|
||||||
return new ArticleDTO
|
|
||||||
{
|
|
||||||
Id = a.Id,
|
|
||||||
Author = a.Author,
|
|
||||||
Title = a.Title,
|
|
||||||
Description = a.Description,
|
|
||||||
LectureTime = a.LectureTime,
|
|
||||||
DatePublished = a.DatePublished
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ArticleEntity ArtDTOToEntity(ArticleDTO a)
|
|
||||||
{
|
|
||||||
return new ArticleEntity()
|
|
||||||
{
|
|
||||||
Id = a.Id,
|
|
||||||
Author = a.Author,
|
|
||||||
Title = a.Title,
|
|
||||||
Description = a.Description,
|
|
||||||
LectureTime = a.LectureTime,
|
|
||||||
DatePublished = a.DatePublished
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormulaireDTO FormEntityToDTO(FormEntity f)
|
|
||||||
{
|
|
||||||
return new FormulaireDTO
|
|
||||||
{
|
|
||||||
Theme = f.Theme,
|
|
||||||
Date = f.DatePublication,
|
|
||||||
Lien = f.Lien,
|
|
||||||
Pseudo = f.Pseudo
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Formulaire FormDTOToEntity(FormulaireDTO f)
|
|
||||||
{
|
|
||||||
return new Formulaire
|
|
||||||
{
|
|
||||||
Theme = f.Theme,
|
|
||||||
Date = f.Date,
|
|
||||||
Lien = f.Lien,
|
|
||||||
Pseudo = f.Pseudo
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserDTO UserEntityToDTO(User u)
|
|
||||||
{
|
|
||||||
return new UserDTO
|
|
||||||
{
|
|
||||||
Pseudo = u.Pseudo,
|
|
||||||
Mail = u.Mail,
|
|
||||||
Prenom = u.Prenom,
|
|
||||||
Nom = u.Nom,
|
|
||||||
Role = u.Role,
|
|
||||||
Mdp = u.Mdp
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public User UserDTOToEntity(UserDTO u)
|
|
||||||
{
|
|
||||||
return new User
|
|
||||||
{
|
|
||||||
Pseudo = u.Pseudo,
|
|
||||||
Mail = u.Mail,
|
|
||||||
Prenom = u.Prenom,
|
|
||||||
Nom = u.Nom,
|
|
||||||
Role = u.Role,
|
|
||||||
Mdp = u.Mdp
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
var summaries = new[]
|
|
||||||
{
|
|
||||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
||||||
};
|
|
||||||
|
|
||||||
app.MapGet("/weatherforecast", () =>
|
|
||||||
{
|
|
||||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
|
||||||
new WeatherForecast
|
|
||||||
(
|
|
||||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
||||||
Random.Shared.Next(-20, 55),
|
|
||||||
summaries[Random.Shared.Next(summaries.Length)]
|
|
||||||
))
|
|
||||||
.ToArray();
|
|
||||||
return forecast;
|
|
||||||
})
|
|
||||||
.WithName("GetWeatherForecast")
|
|
||||||
.WithOpenApi();
|
|
||||||
|
|
||||||
app.Run();
|
|
||||||
|
|
||||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
|
||||||
{
|
|
||||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.2" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\API_Model\API_Model.csproj" />
|
|
||||||
<ProjectReference Include="..\DbContextLib\DbContextLib.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,6 +0,0 @@
|
|||||||
@Web_API_HostAddress = http://localhost:5139
|
|
||||||
|
|
||||||
GET {{Web_API_HostAddress}}/weatherforecast/
|
|
||||||
Accept: application/json
|
|
||||||
|
|
||||||
###
|
|
Loading…
Reference in new issue