using Shared; using DTO; namespace StubApi { public class UserServiceStub : IUserService { private readonly List _users; public UserServiceStub() { _users = new List { new UserDTO { Id = 1, Pseudo = "dev", Password = "1234", Email = "testeur@example.com", date = new DateTime(2025,1,1), ImageProfil = "https://image_profil_1" }, new UserDTO { Id = 2, Pseudo = "admin", Password = "admin123", Email = "admin@example.com", date = new DateTime(2025,1,1), ImageProfil = "https://image_profil_2" }, new UserDTO { Id = 3, Pseudo = "user123", Password = "password123", Email = "user123@example.com", date = new DateTime(2022,1,1), ImageProfil = "https://image_profil_3" }, new UserDTO { Id = 4, Pseudo = "testuser", Password = "testpass", Email = "testuser@example.com", date = new DateTime(2024,1,1), ImageProfil = "https://image_profil_4" }, new UserDTO { Id = 5, Pseudo = "johnDoe", Password = "john123", Email = "johndoe@example.com", date = new DateTime(2021,1,1), ImageProfil = "https://image_profil_5" }, new UserDTO { Id = 6, Pseudo = "janedoe", Password = "jane123", Email = "janedoe@example.com", date = new DateTime(2023,1,1), ImageProfil = "https://image_profil_6" }, new UserDTO { Id = 7, Pseudo = "mark_smith", Password = "mark1234", Email = "marks@example.com", date = new DateTime(2022,1,1), ImageProfil = "https://image_profil_7" }, new UserDTO { Id = 8, Pseudo = "alice", Password = "alicepass", Email = "alice@example.com", date = new DateTime(2025,1,1), ImageProfil = "https://image_profil_8" }, new UserDTO { Id = 9, Pseudo = "bob_lee", Password = "bob123", Email = "bob@example.com", date = new DateTime(2021,1,1), ImageProfil = "https://image_profil_9" }, new UserDTO { Id = 10, Pseudo = "lucas", Password = "lucaspass", Email = "lucas@example.com", date = new DateTime(2023,1,1), ImageProfil = "https://image_profil_10" }, new UserDTO { Id = 11, Pseudo = "emily", Password = "emily2024", Email = "emily@example.com", date = new DateTime(2022,1,1), ImageProfil = "https://image_profil_11" }, new UserDTO { Id = 12, Pseudo = "chris", Password = "chris1234", Email = "chris@example.com", date = new DateTime(2025,1,1), ImageProfil = "https://image_profil_12" }, new UserDTO { Id = 13, Pseudo = "susan", Password = "susan123", Email = "susan@example.com", date = new DateTime(2023,1,1), ImageProfil = "https://image_profil_13" }, new UserDTO { Id = 14, Pseudo = "michael", Password = "michael2025", Email = "michael@example.com", date = new DateTime(2022,1,1), ImageProfil = "https://image_profil_14" }, new UserDTO { Id = 15, Pseudo = "olivia", Password = "olivia2024", Email = "olivia@example.com", date = new DateTime(2025,1,1), ImageProfil = "https://image_profil_15" }, new UserDTO { Id = 16, Pseudo = "david", Password = "david123", Email = "david@example.com", date = new DateTime(2021,1,1), ImageProfil = "https://image_profil_16" }, new UserDTO { Id = 17, Pseudo = "laura", Password = "laura456", Email = "laura@example.com", date = new DateTime(2023,1,1), ImageProfil = "https://image_profil_17" }, new UserDTO { Id = 18, Pseudo = "steve", Password = "steve789", Email = "steve@example.com", date = new DateTime(2022,1,1), ImageProfil = "https://image_profil_18" }, new UserDTO { Id = 19, Pseudo = "tina", Password = "tina321", Email = "tina@example.com", date = new DateTime(2025,1,1), ImageProfil = "https://image_profil_19" }, new UserDTO { Id = 20, Pseudo = "peter", Password = "peter123", Email = "peter@example.com", date = new DateTime(2024,1,1), ImageProfil = "https://image_profil_20" } }; } public async Task AddUser(UserDTO user) { _users.Add(user); } public async Task CountUser() { return _users.Count; } public async Task ExistEmail(string email) { if (_users.FirstOrDefault(u => u.Email == email) == null) return false; return true; } public async Task ExistUsername(string username) { if (_users.FirstOrDefault(u => u.Pseudo == username) == null) return false; return true; } public async Task> GetAllUser() { return new PaginationResult(_users.Count,0,_users.Count, _users); } public async Task GetHashPassword(string username) { return _users.FirstOrDefault(u => u.Pseudo == username).Password; } public async Task GetLastUserId() // JE VOIS PAS L'INTERET { throw new NotImplementedException(); } public async Task> GetSomeUser(int index, int pageSize) { return new PaginationResult(_users.Count, index, pageSize, _users.Skip(index* pageSize).Take(pageSize).ToList()); } public async Task GetUserByEmail(string email) { return _users.FirstOrDefault(u => u.Email == email); } public async Task GetUserById(int id) { return _users.FirstOrDefault(u => u.Id == id); } public async Task GetUserByUsername(string username) { return _users.FirstOrDefault(u => u.Pseudo == username); } public async Task RemoveUser(int id) { var user = await GetUserById(id); _users.Remove(user); } public async Task SetAdminRole(bool isAdmin) { throw new NotImplementedException(); } public async Task UpdateUser(int userId, UserDTO user) { UserDTO userUpdate = new UserDTO(); userUpdate = GetUserById(userId).Result; // Update users properties userUpdate.Pseudo = user.Pseudo; userUpdate.Password = user.Password; userUpdate.Email = user.Email; userUpdate.date = user.date; userUpdate.ImageProfil = user.ImageProfil; return userUpdate; } } }