diff --git a/.gitignore b/.gitignore
index 6fd37d3..d307715 100644
--- a/.gitignore
+++ b/.gitignore
@@ -491,3 +491,7 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
+
+# Migrations et fichiers db
+**/Migrations/**
+*.db
\ No newline at end of file
diff --git a/API_SQLuedo/API/API.csproj b/API_SQLuedo/API/API.csproj
index ba558e4..74687fb 100644
--- a/API_SQLuedo/API/API.csproj
+++ b/API_SQLuedo/API/API.csproj
@@ -8,7 +8,21 @@
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
diff --git a/API_SQLuedo/API/Controllers/UserController.cs b/API_SQLuedo/API/Controllers/UserController.cs
new file mode 100644
index 0000000..1708d72
--- /dev/null
+++ b/API_SQLuedo/API/Controllers/UserController.cs
@@ -0,0 +1,26 @@
+using DbContextLib;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Model.DTO;
+using Services;
+
+namespace API.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class UserController : Controller
+ {
+ private IDataService _userDataService;
+
+ public UserController(IDataService userDataService)
+ {
+ _userDataService = userDataService;
+ }
+
+ [HttpGet("users/{page}/{number}")]
+ public IActionResult GetUsers(int page, int number)
+ {
+ return Ok(_userDataService.GetUsers(page, number));
+ }
+ }
+}
diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs
index 48863a6..ce122da 100644
--- a/API_SQLuedo/API/Program.cs
+++ b/API_SQLuedo/API/Program.cs
@@ -1,3 +1,7 @@
+using DbContextLib;
+using Microsoft.EntityFrameworkCore;
+using Services;
+
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@@ -6,6 +10,8 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
+builder.Services.AddScoped();
+builder.Services.AddDbContext();
var app = builder.Build();
diff --git a/API_SQLuedo/API_SQLuedo.sln b/API_SQLuedo/API_SQLuedo.sln
index a19c322..888826d 100644
--- a/API_SQLuedo/API_SQLuedo.sln
+++ b/API_SQLuedo/API_SQLuedo.sln
@@ -5,6 +5,18 @@ VisualStudioVersion = 17.8.34408.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{65F4AE69-E1CA-4B87-BDF0-946A37351BD1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "EntityFramework\Entities.csproj", "{6D079CDA-C000-4833-98A0-D07D153EA264}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{ADCC427D-A3CD-431C-A90B-F9369C4584E8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAPI", "TestAPI\TestAPI.csproj", "{17025B90-8B2A-49E9-97D3-1A84A208DF50}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestEF", "TestEF\TestEF.csproj", "{54FAD8AF-7601-4C54-8406-D81476A8D7D7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbContextLib", "DbContextLib\DbContextLib.csproj", "{BDCB3BFD-B744-4BC0-BCFC-78E08600203A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{9BD3DCBA-AFD8-47FA-B07C-613B53E63968}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +27,30 @@ Global
{65F4AE69-E1CA-4B87-BDF0-946A37351BD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65F4AE69-E1CA-4B87-BDF0-946A37351BD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65F4AE69-E1CA-4B87-BDF0-946A37351BD1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6D079CDA-C000-4833-98A0-D07D153EA264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6D079CDA-C000-4833-98A0-D07D153EA264}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6D079CDA-C000-4833-98A0-D07D153EA264}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6D079CDA-C000-4833-98A0-D07D153EA264}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ADCC427D-A3CD-431C-A90B-F9369C4584E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ADCC427D-A3CD-431C-A90B-F9369C4584E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ADCC427D-A3CD-431C-A90B-F9369C4584E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ADCC427D-A3CD-431C-A90B-F9369C4584E8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {17025B90-8B2A-49E9-97D3-1A84A208DF50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {17025B90-8B2A-49E9-97D3-1A84A208DF50}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {17025B90-8B2A-49E9-97D3-1A84A208DF50}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {17025B90-8B2A-49E9-97D3-1A84A208DF50}.Release|Any CPU.Build.0 = Release|Any CPU
+ {54FAD8AF-7601-4C54-8406-D81476A8D7D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {54FAD8AF-7601-4C54-8406-D81476A8D7D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {54FAD8AF-7601-4C54-8406-D81476A8D7D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {54FAD8AF-7601-4C54-8406-D81476A8D7D7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BDCB3BFD-B744-4BC0-BCFC-78E08600203A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BDCB3BFD-B744-4BC0-BCFC-78E08600203A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BDCB3BFD-B744-4BC0-BCFC-78E08600203A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BDCB3BFD-B744-4BC0-BCFC-78E08600203A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9BD3DCBA-AFD8-47FA-B07C-613B53E63968}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9BD3DCBA-AFD8-47FA-B07C-613B53E63968}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9BD3DCBA-AFD8-47FA-B07C-613B53E63968}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9BD3DCBA-AFD8-47FA-B07C-613B53E63968}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/API_SQLuedo/DbContextLib/DbContextLib.csproj b/API_SQLuedo/DbContextLib/DbContextLib.csproj
index fa71b7a..38862a9 100644
--- a/API_SQLuedo/DbContextLib/DbContextLib.csproj
+++ b/API_SQLuedo/DbContextLib/DbContextLib.csproj
@@ -6,4 +6,22 @@
enable
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
diff --git a/API_SQLuedo/DbContextLib/UserDbContext.cs b/API_SQLuedo/DbContextLib/UserDbContext.cs
index f231236..c8d8a4f 100644
--- a/API_SQLuedo/DbContextLib/UserDbContext.cs
+++ b/API_SQLuedo/DbContextLib/UserDbContext.cs
@@ -1,21 +1,70 @@
-using Microsoft.EntityFrameworkCore;
+using Entities.SQLudeoDB;
+using Microsoft.AspNetCore.Cryptography.KeyDerivation;
+using Microsoft.EntityFrameworkCore;
+using System.Security.Cryptography;
namespace DbContextLib
{
public class UserDbContext : DbContext
{
+ public DbSet Users { get; set; }
+ public DbSet BlackList { get; set; }
+ public DbSet Inquiry { get; set; }
+ public DbSet InquiryTable { get; set; }
+ public DbSet Lesson { get; set; }
+ public DbSet ContentLessons { get; set; }
+ public DbSet Paragraph { get; set; }
+ public DbSet Solutions { get; set; }
+ public DbSet Success { get; set; }
+ public DbSet Notepad { get; set; }
public UserDbContext(DbContextOptions options) : base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
- optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=password");
+ optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse");
}
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+ modelBuilder.Entity().ToTable("user");
+ modelBuilder.Entity().HasData(
+ new UserEntity(1, "johnny", Convert.ToBase64String(KeyDerivation.Pbkdf2(
+ password: "motdepasse",
+ salt: RandomNumberGenerator.GetBytes(128 / 8),
+ prf: KeyDerivationPrf.HMACSHA256,
+ iterationCount: 100000,
+ numBytesRequested: 256 / 8)), "Johnny.RATTON@etu.uca.fr", true),
+ new UserEntity(2, "maxime", Convert.ToBase64String(KeyDerivation.Pbkdf2(
+ password: "motdepasse",
+ salt: RandomNumberGenerator.GetBytes(128 / 8),
+ prf: KeyDerivationPrf.HMACSHA256,
+ iterationCount: 100000,
+ numBytesRequested: 256 / 8)), "Maxime.SAPOUNTZIS@etu.uca.fr", true),
+ new UserEntity(3, "clement", Convert.ToBase64String(KeyDerivation.Pbkdf2(
+ password: "motdepasse",
+ salt: RandomNumberGenerator.GetBytes(128 / 8),
+ prf: KeyDerivationPrf.HMACSHA256,
+ iterationCount: 100000,
+ numBytesRequested: 256 / 8)), "Clement.CHIEU@etu.uca.fr", true),
+ new UserEntity(4, "erwan", Convert.ToBase64String(KeyDerivation.Pbkdf2(
+ password: "motdepasse",
+ salt: RandomNumberGenerator.GetBytes(128 / 8),
+ prf: KeyDerivationPrf.HMACSHA256,
+ iterationCount: 100000,
+ numBytesRequested: 256 / 8)), "Erwan.MENAGER@etu.uca.fr", true),
+ new UserEntity(5, "victor", Convert.ToBase64String(KeyDerivation.Pbkdf2(
+ password: "motdepasse",
+ salt: RandomNumberGenerator.GetBytes(128 / 8),
+ prf: KeyDerivationPrf.HMACSHA256,
+ iterationCount: 100000,
+ numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true));
+ modelBuilder.Entity().HasKey(c => c.LessonId);
+ modelBuilder.Entity().HasKey(c => c.LessonPartId);
+ modelBuilder.Entity().HasKey(s => s.UserId);
+ modelBuilder.Entity().HasKey(s => s.InquiryId);
base.OnModelCreating(modelBuilder);
}
}
diff --git a/API_SQLuedo/EntityFramework/Entities.csproj b/API_SQLuedo/EntityFramework/Entities.csproj
index fa71b7a..feae017 100644
--- a/API_SQLuedo/EntityFramework/Entities.csproj
+++ b/API_SQLuedo/EntityFramework/Entities.csproj
@@ -6,4 +6,17 @@
enable
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/ContentLessonEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/ContentLessonEntity.cs
index aba1388..f701557 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/ContentLessonEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/ContentLessonEntity.cs
@@ -6,16 +6,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Entities
+namespace Entities.SQLudeoDB
{
- internal class ContentLessonEntity
+ public class ContentLessonEntity
{
- [Key, Column(Order = 0)]
[ForeignKey(nameof(Lesson))]
public int LessonId { get; set; }
public LessonEntity Lesson { get; set; }
- [Key, Column(Order = 1)]
[ForeignKey(nameof(Paragraph))]
public int LessonPartId { get; set; }
public ParagraphEntity Paragraph { get; set; }
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryEntity.cs
index 0b767f6..b3f18b9 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryEntity.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Entities
+namespace Entities.SQLudeoDB
{
public class InquiryEntity
{
@@ -12,7 +12,7 @@ namespace Entities
public string Title { get; set; }
public string Description { get; set; }
public bool IsUser { get; set; }
- public InquiryTableEntity Database { get; set; }
+ public InquiryTableEntity Database { get; set; }
public SolutionEntity InquiryTable { get; set; }
public InquiryEntity() { }
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryTableEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryTableEntity.cs
index 5f1d552..6236273 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryTableEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/InquiryTableEntity.cs
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
-namespace Entities
+namespace Entities.SQLudeoDB
{
public class InquiryTableEntity
{
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/LessonEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/LessonEntity.cs
index c2b9f6c..02cc9ee 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/LessonEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/LessonEntity.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Entities
+namespace Entities.SQLudeoDB
{
public class LessonEntity
{
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/ParagraphEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/ParagraphEntity.cs
index 3fc03bb..aefcc9d 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/ParagraphEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/ParagraphEntity.cs
@@ -1,4 +1,4 @@
-namespace Entities
+namespace Entities.SQLudeoDB
{
public class ParagraphEntity
{
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/SolutionEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/SolutionEntity.cs
index 38b8ce0..db727a0 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/SolutionEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/SolutionEntity.cs
@@ -2,7 +2,7 @@
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography.X509Certificates;
-namespace Entities
+namespace Entities.SQLudeoDB
{
public class SolutionEntity
{
@@ -14,7 +14,7 @@ namespace Entities
public InquiryEntity Owner { get; set; }
public string MurdererFirstName { get; set; }
public string MurdererLastName { get; set; }
- public string MurderPlace { get; set; }
+ public string MurderPlace { get; set; }
public string MurderWeapon { get; set; }
public string Explanation { get; set; }
public SolutionEntity() { }
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/SuccessEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/SuccessEntity.cs
index 7265cc5..780fdd4 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/SuccessEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/SuccessEntity.cs
@@ -10,11 +10,11 @@ namespace Entities.SQLudeoDB
{
public class SuccessEntity
{
- [Key, Column(Order = 0), ForeignKey(nameof(User))]
+ [ForeignKey(nameof(User))]
public int UserId { get; set; }
public UserEntity User { get; set; }
- [Key, Column(Order = 1), ForeignKey(nameof(Inquiry))]
+ [ForeignKey(nameof(Inquiry))]
public int InquiryId { get; set; }
public InquiryEntity Inquiry { get; set; }
public bool IsFinished { get; set; }
diff --git a/API_SQLuedo/EntityFramework/SQLudeoDB/UserEntity.cs b/API_SQLuedo/EntityFramework/SQLudeoDB/UserEntity.cs
index 41d1bf0..4829445 100644
--- a/API_SQLuedo/EntityFramework/SQLudeoDB/UserEntity.cs
+++ b/API_SQLuedo/EntityFramework/SQLudeoDB/UserEntity.cs
@@ -1,5 +1,8 @@
-namespace EntityFramework
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace Entities.SQLudeoDB
{
+ [Table("user")]
public class UserEntity
{
public int Id { get; set; }
@@ -10,7 +13,7 @@
public UserEntity() { }
- public UserEntity(int id, string username, string password, string email, bool isAdmin)
+ public UserEntity(int id, string username, string password, string email, bool isAdmin)
{
Id = id;
Username = username;
diff --git a/API_SQLuedo/Model/Business/User.cs b/API_SQLuedo/Model/Business/User.cs
index 1a66f49..cf60046 100644
--- a/API_SQLuedo/Model/Business/User.cs
+++ b/API_SQLuedo/Model/Business/User.cs
@@ -1,7 +1,21 @@
namespace Model.Business
{
- public class UserDTO
+ public class User
{
+ public int Id { get; set; }
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public string Email { get; set; }
+ public bool IsAdmin { get; set; }
+ public User() { }
+ public User(int id, string username, string password, string email, bool isAdmin)
+ {
+ Id = id;
+ Username = username;
+ Password = password;
+ Email = email;
+ IsAdmin = isAdmin;
+ }
}
}
diff --git a/API_SQLuedo/Model/DTO/UserDTO.cs b/API_SQLuedo/Model/DTO/UserDTO.cs
index 86cde9a..786fad7 100644
--- a/API_SQLuedo/Model/DTO/UserDTO.cs
+++ b/API_SQLuedo/Model/DTO/UserDTO.cs
@@ -8,5 +8,20 @@ namespace Model.DTO
{
public class UserDTO
{
+ public int Id { get; set; }
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public string Email { get; set; }
+ public bool IsAdmin { get; set; }
+
+ public UserDTO() { }
+ public UserDTO(int id, string username, string password, string email, bool isAdmin)
+ {
+ Id = id;
+ Username = username;
+ Password = password;
+ Email = email;
+ IsAdmin = isAdmin;
+ }
}
}
diff --git a/API_SQLuedo/Model/Mappers/IMapper.cs b/API_SQLuedo/Model/Mappers/IMapper.cs
index ff4c6cb..01790e5 100644
--- a/API_SQLuedo/Model/Mappers/IMapper.cs
+++ b/API_SQLuedo/Model/Mappers/IMapper.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.InteropServices.ObjectiveC;
using System.Text;
using System.Threading.Tasks;
@@ -8,9 +9,9 @@ namespace Model.Mappers
{
public interface IMapper
{
- public Object FromEntityToModel();
- public Object FromModelToDTO();
- public Object FromDTOToModel();
- public Object FromModelToEntity();
+ public Object FromEntityToModel(object o);
+ public Object FromModelToDTO(object o);
+ public Object FromDTOToModel(object o);
+ public Object FromModelToEntity(object o);
}
}
diff --git a/API_SQLuedo/Model/Mappers/InquiryMapper.cs b/API_SQLuedo/Model/Mappers/InquiryMapper.cs
index 33a4140..c4e916e 100644
--- a/API_SQLuedo/Model/Mappers/InquiryMapper.cs
+++ b/API_SQLuedo/Model/Mappers/InquiryMapper.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Model.Mappers
{
- public class InquiryMapper : IMapper
+ public class InquiryMapper
{
public object FromDTOToModel()
{
diff --git a/API_SQLuedo/Model/Mappers/UserMapper.cs b/API_SQLuedo/Model/Mappers/UserMapper.cs
index 5bc189c..d62cad7 100644
--- a/API_SQLuedo/Model/Mappers/UserMapper.cs
+++ b/API_SQLuedo/Model/Mappers/UserMapper.cs
@@ -1,31 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Entities.SQLudeoDB;
+using Model.Business;
+using Model.DTO;
namespace Model.Mappers
{
- public class UserMapper : IMapper
+ public static class UserMapper
{
- public object FromDTOToModel()
+ public static User FromDTOToModel(this UserDTO dto)
{
- throw new NotImplementedException();
+ return new User(dto.Id, dto.Username, dto.Password, dto.Email, dto.IsAdmin);
}
- public object FromEntityToModel()
+ public static User FromEntityToModel(this UserEntity entity)
{
- throw new NotImplementedException();
+ return new User(entity.Id, entity.Username, entity.Password, entity.Email, entity.IsAdmin);
}
- public object FromModelToDTO()
+ public static UserDTO FromModelToDTO(this User user)
{
- throw new NotImplementedException();
+ return new UserDTO(user.Id, user.Username, user.Password, user.Email, user.IsAdmin);
}
- public object FromModelToEntity()
+ public static UserEntity FromModelToEntity(this User user)
{
- throw new NotImplementedException();
+ return new UserEntity(user.Id, user.Username, user.Password, user.Email, user.IsAdmin);
}
}
}
diff --git a/API_SQLuedo/Model/Model.csproj b/API_SQLuedo/Model/Model.csproj
index fa71b7a..b46af5d 100644
--- a/API_SQLuedo/Model/Model.csproj
+++ b/API_SQLuedo/Model/Model.csproj
@@ -6,4 +6,21 @@
enable
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
diff --git a/API_SQLuedo/Services/Services.csproj b/API_SQLuedo/Services/Services.csproj
index fa71b7a..4cd7b1b 100644
--- a/API_SQLuedo/Services/Services.csproj
+++ b/API_SQLuedo/Services/Services.csproj
@@ -6,4 +6,23 @@
enable
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
diff --git a/API_SQLuedo/Services/UserDataService.cs b/API_SQLuedo/Services/UserDataService.cs
new file mode 100644
index 0000000..c3206d9
--- /dev/null
+++ b/API_SQLuedo/Services/UserDataService.cs
@@ -0,0 +1,41 @@
+using DbContextLib;
+using Model.DTO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Model.Mappers;
+using Model.Business;
+
+namespace Services
+{
+ public class UserDataService : IDataService
+ {
+ private UserDbContext DbContext { get; set; }
+ public UserDataService(UserDbContext context)
+ {
+ DbContext = context;
+ context.Database.EnsureCreated();
+ }
+ public IEnumerable GetInquiries()
+ {
+ throw new NotImplementedException();
+ }
+
+ public UserDTO GetUserById(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public UserDTO GetUserByUsername(string username)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IEnumerable GetUsers(int page, int number)
+ {
+ return DbContext.Users.Skip((page - 1) * number).Take(number).ToList().Select(u => u.FromEntityToModel().FromModelToDTO());
+ }
+ }
+}
diff --git a/API_SQLuedo/TestAPI/TestAPI.csproj b/API_SQLuedo/TestAPI/TestAPI.csproj
index 9e0c306..bda60d7 100644
--- a/API_SQLuedo/TestAPI/TestAPI.csproj
+++ b/API_SQLuedo/TestAPI/TestAPI.csproj
@@ -10,7 +10,17 @@
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/API_SQLuedo/TestEF/TestEF.csproj b/API_SQLuedo/TestEF/TestEF.csproj
index 9e0c306..bda60d7 100644
--- a/API_SQLuedo/TestEF/TestEF.csproj
+++ b/API_SQLuedo/TestEF/TestEF.csproj
@@ -10,7 +10,17 @@
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive