2024-10-16 20:15:49 +00:00
|
|
|
using Demo.Data.LocalData;
|
|
|
|
using Demo.domain.Models;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace Demo.Data.Repository
|
|
|
|
{
|
|
|
|
public class UserRepositoryImpl
|
|
|
|
{
|
|
|
|
public UserRepositoryImpl() {
|
|
|
|
|
|
|
|
GetAllUsers = LocalStaticData.users;
|
|
|
|
}
|
|
|
|
public List<UserLocalEntity> GetAllUsers
|
|
|
|
{ get; set; }
|
|
|
|
|
|
|
|
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? GetUserByGuid(Guid userGuid) {
|
|
|
|
UserLocalEntity? userLocal = GetAllUsers
|
|
|
|
.Where(x => x.Guid == userGuid).FirstOrDefault();
|
|
|
|
if (userLocal == null) return null;
|
|
|
|
|
|
|
|
return userLocal;
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserLocalEntity? UpdateUser(UserLocalEntity userUpdateLocalEntity) {
|
2024-10-17 12:35:14 +00:00
|
|
|
int index = GetAllUsers.FindIndex(x => x.Guid == userUpdateLocalEntity.Guid);
|
|
|
|
if (index == -1) return null;
|
|
|
|
GetAllUsers[index].FIO = userUpdateLocalEntity.FIO;
|
|
|
|
GetAllUsers[index].GroupID = userUpdateLocalEntity.GroupID;
|
|
|
|
return GetAllUsers[index];
|
2024-10-16 20:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|