using AttendanceApp.Data.Exceptions; using AttendanceApp.Data.LocalData; using AttendanceApp.Domain.Models; namespace AttendanceApp.Data.Repository { public class UserRepositoryImpl : IUserRepository { private readonly List _users = LocalStaticData.Users; public IEnumerable GetAllUsers() { return _users.Select(u => new User { Id = u.Id, FIO = u.FIO, GroupId = u.GroupID }); } public User GetUserById(Guid id) { var localUser = _users.FirstOrDefault(u => u.Id == id); if (localUser == null) throw new UserNotFoundException($"Пользователь с ID {id} не найден."); return new User { Id = localUser.Id, FIO = localUser.FIO, GroupId = localUser.GroupID }; } public void AddUser(User user) { _users.Add(new LocalUser { Id = user.Id, FIO = user.FIO, GroupID = user.GroupId }); } public void UpdateUser(User user) { var localUser = _users.FirstOrDefault(u => u.Id == user.Id); if (localUser == null) throw new UserNotFoundException($"Пользователь с ID {user.Id} не найден."); localUser.FIO = user.FIO; localUser.GroupID = user.GroupId; } public void DeleteUser(Guid id) { var user = _users.FirstOrDefault(u => u.Id == id); if (user == null) throw new UserNotFoundException($"Пользователь с ID {id} не найден."); _users.Remove(user); } } }