Studety/Demo/Data/Repository/UserRepositoryImpl.cs

51 lines
1.5 KiB
C#
Raw Permalink Normal View History

2024-10-18 06:12:15 +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;
}
2024-10-18 06:49:19 +00:00
2024-10-18 06:12:15 +00:00
public List<UserLocalEnity> GetAllUsers
{ get; set; }
public bool RemoveUserByGuid(Guid userGuid)
{
UserLocalEnity? userLocal = GetAllUsers
.Where(x => x.Guid == userGuid).FirstOrDefault();
if (userLocal == null) return false;
return GetAllUsers.Remove(userLocal);
}
public UserLocalEnity? GetUserByGuid(Guid userGuid) {
UserLocalEnity? userLocal = GetAllUsers
.Where(x => x.Guid == userGuid).FirstOrDefault();
if (userLocal == null) return null;
return userLocal;
}
public UserLocalEnity? UpdateUser(UserLocalEnity userUpdateLocalEnity) {
UserLocalEnity? 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 07:04:09 +00:00
public List<UserLocalEnity> GetAllUsersList()
{
return GetAllUsers;
}
2024-10-18 06:12:15 +00:00
}
2024-10-18 07:04:09 +00:00
}