2024-10-14 11:19:48 +00:00
|
|
|
|
using Demo.Data.LocalData;
|
|
|
|
|
using Demo.domain.Models;
|
|
|
|
|
using System;
|
2024-10-14 10:42:14 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Demo.Data.Repository
|
|
|
|
|
{
|
2024-10-14 11:19:48 +00:00
|
|
|
|
public class UserRepositoryImpl
|
2024-10-14 10:42:14 +00:00
|
|
|
|
{
|
2024-10-16 07:01:04 +00:00
|
|
|
|
public UserRepositoryImpl() {
|
|
|
|
|
|
|
|
|
|
GetAllUsers = LocalStaticData.users;
|
|
|
|
|
}
|
|
|
|
|
public List<UserLocalEnity> GetAllUsers
|
|
|
|
|
{ get; set; }
|
2024-10-14 11:19:48 +00:00
|
|
|
|
|
|
|
|
|
public bool RemoveUserByGuid(Guid userGuid)
|
|
|
|
|
{
|
2024-10-16 07:01:04 +00:00
|
|
|
|
UserLocalEnity? userLocal = GetAllUsers
|
2024-10-14 11:19:48 +00:00
|
|
|
|
.Where(x => x.Guid == userGuid).FirstOrDefault();
|
|
|
|
|
if (userLocal == null) return false;
|
|
|
|
|
|
2024-10-16 07:01:04 +00:00
|
|
|
|
return GetAllUsers.Remove(userLocal);
|
2024-10-14 11:19:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserLocalEnity? GetUserByGuid(Guid userGuid) {
|
2024-10-16 07:01:04 +00:00
|
|
|
|
UserLocalEnity? userLocal = GetAllUsers
|
2024-10-14 11:19:48 +00:00
|
|
|
|
.Where(x => x.Guid == userGuid).FirstOrDefault();
|
|
|
|
|
if (userLocal == null) return null;
|
|
|
|
|
|
|
|
|
|
return userLocal;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-14 11:51:48 +00:00
|
|
|
|
public UserLocalEnity? UpdateUser(UserLocalEnity userUpdateLocalEnity) {
|
2024-10-16 07:01:04 +00:00
|
|
|
|
UserLocalEnity? userLocal = GetAllUsers
|
2024-10-14 11:19:48 +00:00
|
|
|
|
.Where(x => x.Guid == userUpdateLocalEnity.Guid).FirstOrDefault();
|
|
|
|
|
if (userLocal == null) return null;
|
|
|
|
|
userLocal.FIO = userUpdateLocalEnity.FIO;
|
|
|
|
|
userLocal.GroupID = userUpdateLocalEnity.GroupID;
|
|
|
|
|
return userLocal;
|
|
|
|
|
|
|
|
|
|
}
|
2024-10-14 10:42:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|