2024-10-17 16:08:02 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Posechaemost.Data.LocalData;
|
|
|
|
using Posechaemost.Data.LocalData.Entity;
|
|
|
|
|
|
|
|
namespace Posechaemost.Data.Repository
|
|
|
|
{
|
2024-10-23 07:06:56 +00:00
|
|
|
public class UserRepositoryImpl: IUserRepository
|
2024-10-17 16:08:02 +00:00
|
|
|
{
|
|
|
|
public UserRepositoryImpl() {
|
|
|
|
|
|
|
|
GetAllUsers = LocalStaticData.users;
|
|
|
|
}
|
2024-10-23 07:06:56 +00:00
|
|
|
|
|
|
|
public List<UserLocalEntity> GetAllUser()
|
|
|
|
{
|
2024-10-24 11:13:46 +00:00
|
|
|
return GetAllUsers;
|
2024-10-23 07:06:56 +00:00
|
|
|
}
|
|
|
|
|
2024-10-17 16:08:02 +00:00
|
|
|
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 userUpdateLocalEnity) {
|
|
|
|
UserLocalEntity? userLocal = GetAllUsers
|
|
|
|
.Where(x => x.Guid == userUpdateLocalEnity.Guid).FirstOrDefault();
|
|
|
|
if (userLocal == null) return null;
|
|
|
|
userLocal.FIO = userUpdateLocalEnity.FIO;
|
|
|
|
userLocal.GroupID = userUpdateLocalEnity.GroupID;
|
|
|
|
return userLocal;
|
|
|
|
|
|
|
|
}
|
2024-10-18 08:27:50 +00:00
|
|
|
|
|
|
|
public UserLocalEntity? UpdateUserByGuid(Guid userGuid) {
|
|
|
|
UserLocalEntity? userLocal = GetAllUsers
|
|
|
|
.Where(x => x.Guid == userGuid).FirstOrDefault();
|
|
|
|
if (userLocal == null) return null;
|
|
|
|
return userLocal;
|
|
|
|
}
|
2024-10-17 16:08:02 +00:00
|
|
|
}
|
|
|
|
}
|