presence/Demo/Data/Repository/UserRepositoryImpl.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2024-10-21 12:41:56 +00:00
using Demo.Data.Exceptions;
using Demo.Data.LocalData;
2024-10-25 08:47:11 +00:00
using Demo.Data.RemoteData.RemoteDataBase.DAO;
2024-10-21 12:41:56 +00:00
using Demo.domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Demo.Data.Repository
{
2024-10-28 12:03:51 +00:00
public class UserRepositoryImpl
2024-10-21 12:41:56 +00:00
{
private List<UserLocalEnity> _users;
public UserRepositoryImpl()
{
_users = LocalStaticData.users;
}
public IEnumerable<UserLocalEnity> GetAllUsers => _users;
2024-10-25 08:47:11 +00:00
2024-10-21 12:41:56 +00:00
public bool RemoveUserById(int userId)
{
var user = _users.FirstOrDefault(u => u.ID == userId);
if (user == null) throw new UserNotFoundException(userId);
_users.Remove(user);
return true;
}
public UserLocalEnity? UpdateUser(UserLocalEnity user)
{
2024-10-28 12:03:51 +00:00
var existingUser = _users.FirstOrDefault(u => u.ID == user.ID);
2024-10-21 12:41:56 +00:00
if (existingUser == null) throw new UserNotFoundException(user.ID);
existingUser.FIO = user.FIO;
existingUser.GroupID = user.GroupID;
return existingUser;
}
2024-10-25 08:47:11 +00:00
2024-10-28 12:03:51 +00:00
public UserDao? UpdateUser(UserDao user)
2024-10-25 08:47:11 +00:00
{
throw new NotImplementedException();
}
2024-10-21 12:41:56 +00:00
}
}