presense/Demo/Domain/UseCase/UserUseCase.cs
2024-10-18 16:23:16 +03:00

45 lines
1.2 KiB
C#

using Demo.Data.Repository;
using Demo.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class UserUseCase
{
private List<User> _users = new List<User>();
private UserRepositoryImpl userRepositoryImpl;
private GroupRepositoryImpl groupRepositoryImpl;
public UserUseCase(UserRepositoryImpl userRepositoryImpl, GroupRepositoryImpl groupRepositoryImpl)
{
this.userRepositoryImpl = userRepositoryImpl;
this.groupRepositoryImpl = groupRepositoryImpl;
}
public IEnumerable<User> GetAllUsers() => _users;
public User FindUserByGuid(Guid id) => _users.FirstOrDefault(u => u. Guid == id);
public void DeleteUserByGuid(Guid id)
{
var user = _users.FirstOrDefault(u => u.Guid == id);
if (user != null)
_users.Remove(user);
}
public void UpdateUserByGuid(Guid id, string newName)
{
var user = _users.FirstOrDefault(u => u.Guid == id);
if (user != null)
user.FIO = newName;
}
internal bool RemoveUserByGuid(Guid guidUser)
{
throw new NotImplementedException();
}
}