using Zurnal.domain.Models;
using Zurnal.Date.LocalDate;
using Zurnal.Domain.UseCase;
using Zurnal.RemaDateBase.DateDao;

namespace Zurnal.Data.Repository
{
    public class UserRepositoryImpl : IGroupRepository
    {
        public UserRepositoryImpl() => GetAllUsers = LocalStaticData.users;

        public List<UserLocalEnity> GetAllUsers { get; set; }

        public List<GroupDao> AllGroup => throw new NotImplementedException();

        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;
        }

        public List<UserLocalEnity> GetAllUsersList()
        {
            return GetAllUsers;
        }
    }
}