Fonction CRUD

pull/4/head
Alexandre Ruiz 3 years ago
parent 61d64beaea
commit d683ef85e7
  1. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionController.cs
  2. 3
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  3. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/FonctionApiDto.cs
  4. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/FonctionMapper.cs
  5. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionService.cs
  6. 17
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeFonctionRepository.cs
  7. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IFonctionRepository.cs
  8. 30
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/AgenceSqlDto.cs
  9. 35
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/BusinessUnitSqlDto.cs
  10. 90
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurSqlDto.cs
  11. 32
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs
  12. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/FonctionSqlRepository.cs

@ -0,0 +1,12 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers
{
public class FonctionController : BaseController<FonctionApiDto>
{
public FonctionController(FonctionService fonctionService) : base(fonctionService)
{
}
}
}

@ -14,12 +14,14 @@ internal static class Register
services.AddScoped<CollaborateursService>();
services.AddScoped<AgenceService>();
services.AddScoped<BusinessUnitService>();
services.AddScoped<FonctionService>();
if (contextOptions.LoadFake)
{
services.AddSingleton<ICollaborateurRepository, FakeCollaborateurRepository>();
services.AddSingleton<IAgenceRepository, FakeAgenceRepository>();
services.AddSingleton<IBusinessUnitRepository, FakeBusinessUnitRepository>();
services.AddSingleton<IFonctionRepository, FakeFonctionRepository>();
}
else
{
@ -27,6 +29,7 @@ internal static class Register
services.AddScoped<ICollaborateurRepository, CollaborateurSqlRepository>();
services.AddScoped<IAgenceRepository, AgenceSqlRepository>();
services.AddScoped<IBusinessUnitRepository, BusinessUnitSqlRepository>();
services.AddScoped<IFonctionRepository, FonctionSqlRepository>();
}
}
}

@ -0,0 +1,8 @@
using espacecollab.backend.appservices.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record FonctionApiDto(uint Id, string Name) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class FonctionMapper
{
public static FonctionApiDto ToApi(this FonctionSqlDto fonctionSqlDto)
{
return new FonctionApiDto((uint)fonctionSqlDto.Id, fonctionSqlDto.Name);
}
public static FonctionSqlDto ToSql(this FonctionApiDto fonctionApiDto)
{
return new FonctionSqlDto((int)fonctionApiDto.Id, fonctionApiDto.Name);
}
}

@ -0,0 +1,14 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class FonctionService : GenericsServices<FonctionSqlDto, FonctionApiDto>
{
public FonctionService(IFonctionRepository fonctionRepository)
:base(fonctionRepository, FonctionMapper.ToApi, FonctionMapper.ToSql)
{
}
}

@ -0,0 +1,17 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.fake;
public class FakeFonctionRepository : GenericFakeRepository<FonctionSqlDto>, IFonctionRepository
{
public FakeFonctionRepository()
{
Context = new List<FonctionSqlDto>
{
new(1, "Fonction 1"),
new(2, "Fonction 2")
};
}
}

@ -0,0 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IFonctionRepository : IGenericRepository<FonctionSqlDto>
{
}

@ -1,24 +1,22 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class AgenceSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
namespace espacecollab.backend.infrastructure.sql.dtos;
[ExcludeFromCodeCoverage]
public class AgenceSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
private AgenceSqlDto()
{
}
[ExcludeFromCodeCoverage]
public AgenceSqlDto(int id, string name)
{
Id = id;
Name = name;
}
private AgenceSqlDto()
{
}
public AgenceSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}
}

@ -1,27 +1,24 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class BusinessUnitSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
public int AgenceId { get; set; }
namespace espacecollab.backend.infrastructure.sql.dtos;
public class BusinessUnitSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
public int AgenceId { get; set; }
[ExcludeFromCodeCoverage]
private BusinessUnitSqlDto()
{
}
public BusinessUnitSqlDto(int id, string name, int agenceId)
{
Id = id;
Name = name;
AgenceId = agenceId;
}
[ExcludeFromCodeCoverage]
private BusinessUnitSqlDto()
{
}
public BusinessUnitSqlDto(int id, string name, int agenceId)
{
Id = id;
Name = name;
AgenceId = agenceId;
}
}
}

@ -2,53 +2,51 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class CollaborateurSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
public string FirstName { get; set; }
public DateTime BirthDate { get; set; }
public EnumGenreSql Gender { get; set; }
public EnumStatutSql Status { get; set; }
public int ChildrenNumber { get; set; }
public string Address { get; set; }
public string Telephone { get; set; }
public string PersonalMail { get; set; }
public string ApsideMail { get; set; }
public DateTime ResignationDate { get; set; }
public int ReferrerId { get; set; }
public int BusinessUnitId { get; set; }
namespace espacecollab.backend.infrastructure.sql.dtos;
[ExcludeFromCodeCoverage]
private CollaborateurSqlDto()
{
Name = string.Empty;
FirstName = string.Empty;
Address = string.Empty;
Telephone = string.Empty;
PersonalMail = string.Empty;
ApsideMail = string.Empty;
}
public class CollaborateurSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
public string FirstName { get; set; }
public DateTime BirthDate { get; set; }
public EnumGenreSql Gender { get; set; }
public EnumStatutSql Status { get; set; }
public int ChildrenNumber { get; set; }
public string Address { get; set; }
public string Telephone { get; set; }
public string PersonalMail { get; set; }
public string ApsideMail { get; set; }
public DateTime ResignationDate { get; set; }
public int ReferrerId { get; set; }
public int BusinessUnitId { get; set; }
public CollaborateurSqlDto(int id, string name, string firstName, DateTime birthDate, EnumGenreSql gender, EnumStatutSql status, int childrenNumber, string address, string telephone, string personalMail, string apsideMail, DateTime resignationDate, int referrerId, int businessUnitId)
{
Id = id;
Name = name;
FirstName = firstName;
BirthDate = birthDate;
Gender = gender;
Status = status;
ChildrenNumber = childrenNumber;
Address = address;
Telephone = telephone;
PersonalMail = personalMail;
ApsideMail = apsideMail;
ResignationDate = resignationDate;
ReferrerId = referrerId;
BusinessUnitId = businessUnitId;
}
[ExcludeFromCodeCoverage]
private CollaborateurSqlDto()
{
Name = string.Empty;
FirstName = string.Empty;
Address = string.Empty;
Telephone = string.Empty;
PersonalMail = string.Empty;
ApsideMail = string.Empty;
}
public CollaborateurSqlDto(int id, string name, string firstName, DateTime birthDate, EnumGenreSql gender, EnumStatutSql status, int childrenNumber, string address, string telephone, string personalMail, string apsideMail, DateTime resignationDate, int referrerId, int businessUnitId)
{
Id = id;
Name = name;
FirstName = firstName;
BirthDate = birthDate;
Gender = gender;
Status = status;
ChildrenNumber = childrenNumber;
Address = address;
Telephone = telephone;
PersonalMail = personalMail;
ApsideMail = apsideMail;
ResignationDate = resignationDate;
ReferrerId = referrerId;
BusinessUnitId = businessUnitId;
}
}
}

@ -1,24 +1,22 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class FonctionSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
namespace espacecollab.backend.infrastructure.sql.dtos;
[ExcludeFromCodeCoverage]
private FonctionSqlDto()
{
}
public FonctionSqlDto(int id, string name)
{
Id = id;
Name = name;
}
public class FonctionSqlDto : IGenericIdSqlDto
{
public int Id { get; set; }
public string Name { get; set; }
[ExcludeFromCodeCoverage]
private FonctionSqlDto()
{
}
public FonctionSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}
}

@ -0,0 +1,11 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class FonctionSqlRepository : GenericSqlRepository<FonctionSqlDto>, IFonctionRepository
{
public FonctionSqlRepository(MainDbContext context) : base(context)
{
}
}
Loading…
Cancel
Save