46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Demo.Domain.Models;
|
|
using Demo.Data.LocalData;
|
|
|
|
namespace Demo.Data.Repository
|
|
{
|
|
public class UserRepositoryImpl
|
|
{
|
|
public UserRepositoryImpl() {
|
|
|
|
GetAllUsers = LocalStaticData.users;
|
|
}
|
|
public List<UserLocalEntity> GetAllUsers
|
|
{ get; set; }
|
|
|
|
public List<UserLocalEntity> GeAllUser(){
|
|
return GetAllUsers;
|
|
}
|
|
|
|
public bool RemoveUserByGuid(Guid userGuid)
|
|
{
|
|
UserLocalEntity? userLocal = GetAllUsers
|
|
.Where(x => x.Guid == userGuid).FirstOrDefault();
|
|
if (userLocal == null) return false;
|
|
|
|
return GetAllUsers.Remove(userLocal);
|
|
}
|
|
|
|
public UserLocalEntity? GetUserById(Guid userGuid)
|
|
{
|
|
UserLocalEntity? userlocal = LocalStaticData.users.Where(x => x.Guid == userGuid).FirstOrDefault();
|
|
if (userlocal == null) return null;
|
|
|
|
return userlocal;
|
|
}
|
|
|
|
public UserLocalEntity? UpdateUserById(UserLocalEntity userUpdateLocalEntity)
|
|
{
|
|
int index = GetAllUsers.FindIndex(x => x.Guid == userUpdateLocalEntity.Guid);
|
|
if (index == -1) return null;
|
|
GetAllUsers[index].FIO = userUpdateLocalEntity.FIO;
|
|
GetAllUsers[index].GroupID = userUpdateLocalEntity.GroupID;
|
|
Console.WriteLine($"Обновленный FIO: {GetAllUsers[index].FIO}, GroupID: {GetAllUsers[index].GroupID}");
|
|
return GetAllUsers[index];
|
|
}
|
|
}
|
|
} |