Déplacement des dto et suppression d'une couche de hiérarchie inutile

pull/29/head
Clement CHIEU 1 year ago
parent 375af949e7
commit ecdd8c8f56

@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model.DTO;
using Services;
namespace API.Controllers
@ -21,9 +20,9 @@ namespace API.Controllers
[HttpGet("inquiries/{page}/{number}")]
public IActionResult GetInquiries(int page, int number)
{
{
var nbInquiry = _inquiryDataService.GetInquiries(page, number).Count();
if (nbInquiry == 0)
if (nbInquiry == 0)
{
_logger.LogError("[ERREUR] Aucune enquête trouvé.");
return StatusCode(204);
@ -34,13 +33,13 @@ namespace API.Controllers
[HttpGet("inquiry/id/{id}")]
public IActionResult GetInquiryById(int id)
{
{
try
{
_logger.LogInformation("[INFORMATION] Enquête avec l'id {id} a été trouvé.", id);
return Ok(_inquiryDataService.GetInquiryById(id));
}
catch (ArgumentException)
}
catch (ArgumentException)
{
_logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id);
return NotFound();
@ -49,13 +48,13 @@ namespace API.Controllers
[HttpGet("inquiry/title/{title}")]
public IActionResult GetInquiryByTitle(string title)
{
{
try
{
_logger.LogInformation("[INFORMATION] Enquête avec le titre {title} a été trouvé.", title);
return Ok(_inquiryDataService.GetInquiryByTitle(title));
}
catch (ArgumentException)
}
catch (ArgumentException)
{
_logger.LogError("[ERREUR] Aucune enquête trouvée avec le titre {title}.", title);
return NotFound();

@ -1,9 +1,9 @@
using DbContextLib;
using Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model.Business;
using Model.DTO;
using Services;
namespace API.Controllers
@ -14,8 +14,8 @@ namespace API.Controllers
[ApiController]
public class UserController : Controller
{
private IDataService _userDataService;
private IDataService _userDataService;
private readonly ILogger<UserController> _logger;
public UserController(IDataService userDataService, ILogger<UserController> logger)
@ -85,9 +85,9 @@ namespace API.Controllers
[HttpPost]
public IActionResult CreateUser([FromBody]UserDTO dto)
{
if (dto.Username == null || dto.Password == null || dto.Email == null)
{
return BadRequest();
if (dto.Username == null || dto.Password == null || dto.Email == null)
{
return BadRequest();
}
// return Ok(_userDataService.CreateUser(username, password, email, isAdmin));
_logger.LogInformation("[INFORMATION] Un utilisateur a été créé : username - {username}, password - {password}, email - {email}, isAdmin - {isAdmin}", dto.Username, dto.Password, dto.Email, dto.IsAdmin);
@ -98,7 +98,7 @@ namespace API.Controllers
public IActionResult UpdateUser(int id, [FromBody] UserDTO userDTO)
{
if(id != userDTO.Id)
{
{
_logger.LogError("[ERREUR] Problème ID - La mise à jour de l'utilisateur avec l'id {id} a échouée.", id);
return BadRequest();
}

@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleAPI", "TestConso
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{B64941C9-0550-4C47-89B6-396F6DB0486D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dto", "Dto\Dto.csproj", "{9682CA6B-2380-463B-B6BC-17C3B9E992C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -63,6 +65,10 @@ Global
{B64941C9-0550-4C47-89B6-396F6DB0486D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B64941C9-0550-4C47-89B6-396F6DB0486D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B64941C9-0550-4C47-89B6-396F6DB0486D}.Release|Any CPU.Build.0 = Release|Any CPU
{9682CA6B-2380-463B-B6BC-17C3B9E992C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9682CA6B-2380-463B-B6BC-17C3B9E992C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9682CA6B-2380-463B-B6BC-17C3B9E992C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9682CA6B-2380-463B-B6BC-17C3B9E992C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class BlackListDTO
{

@ -1,12 +1,4 @@
using Entities.SQLuedoDB;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Business
namespace Dto
{
public class ContentLessonDTO
{

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -1,11 +1,4 @@
using Entities.SQLuedoDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class InquiryDTO
{

@ -1,11 +1,4 @@
using Model.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class InquiryTableDTO
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class LessonDTO
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class NotepadDTO
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class ParagraphDTO
{

@ -1,11 +1,4 @@
using Model.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class SolutionDTO
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class SuccessDTO
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.DTO
namespace Dto
{
public class UserDTO
{

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -1,10 +1,10 @@
using Model.Business;
using Model.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
namespace Model.Mappers

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -3,9 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{
public static class ParagraphMapper

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -1,6 +1,6 @@
using Entities.SQLuedoDB;
using Dto;
using Entities.SQLuedoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{

@ -20,6 +20,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dto\Dto.csproj" />
<ProjectReference Include="..\EntityFramework\Entities.csproj" />
</ItemGroup>

@ -1,5 +1,5 @@
using Model.Business;
using Model.DTO;
using Dto;
using Model.Business;
namespace Services
{

@ -1,10 +1,10 @@
using DbContextLib;
using Model.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dto;
using Model.Mappers;
using Model.Business;
using Microsoft.EntityFrameworkCore;
@ -92,16 +92,16 @@ namespace Services
public IEnumerable<InquiryDTO> GetInquiries(int page, int number)
{
throw new NotImplementedException();
}
public InquiryDTO GetInquiryById(int id)
{
throw new NotImplementedException();
}
public InquiryDTO GetInquiryByTitle(string title)
{
throw new NotImplementedException();
}
}
public InquiryDTO GetInquiryById(int id)
{
throw new NotImplementedException();
}
public InquiryDTO GetInquiryByTitle(string title)
{
throw new NotImplementedException();
}
}
}

@ -2,12 +2,12 @@
using API.Controllers;
using DbContextLib;
using Dto;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Model.DTO;
using Services;
var connection = new SqliteConnection("DataSource=:memory:");

Loading…
Cancel
Save