From fc4f46d1b71e2fc7627d8240f67cbde2e1e2b069 Mon Sep 17 00:00:00 2001 From: Userok Date: Sat, 2 Nov 2024 10:59:27 +0300 Subject: [PATCH] Vozmozno eto rabotaet --- Zurnal/Domain/UseCase/UserUseCase.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Zurnal/Domain/UseCase/UserUseCase.cs b/Zurnal/Domain/UseCase/UserUseCase.cs index 3e34f6b..6369f49 100644 --- a/Zurnal/Domain/UseCase/UserUseCase.cs +++ b/Zurnal/Domain/UseCase/UserUseCase.cs @@ -31,19 +31,19 @@ namespace Zurnal.Domain.UseCase return _repositoryUserImpl.RemoveUserByGuid(userGuid); } - public User UpdateUser(User user, Group id) - { - UserLocalEntity userLocalEntity = new UserLocalEntity { FIO = user.FIO, GroupID = id, Guid = user.Guid }; - UserLocalEntity? result = _repositoryUserImpl.UpdateUser(userLocalEntity); - if (result == null) throw new Exception("User update failed."); - Group? group = GetAllGroups().FirstOrDefault(it => it.Id == result.GroupID.ToString()); - if (group == null) throw new Exception("Group not found."); - return new User { FIO = user.FIO, Guid = user.Guid, Group = group }; - } + public User UpdateUser(User user, int groupId) +{ + UserLocalEntity userLocalEntity = new UserLocalEntity { FIO = user.FIO, GroupID = groupId, Guid = user.Guid }; + UserLocalEntity? result = _repositoryUserImpl.UpdateUser(userLocalEntity); + if (result == null) throw new Exception("User update failed."); + Group? group = GetAllGroups().FirstOrDefault(it => it.Id == result.GroupID); + if (group == null) throw new Exception("Group not found."); + return new User { FIO = user.FIO, Guid = user.Guid, Group = group }; +} private List GetAllGroups() { - return new List(); + return RepositoryGroupImpl.AllGroup.Select(g => new Group { Id = g.Id, Name = g.GroupName }).ToList(); } public User FindUserByGuid(Guid userGuid) @@ -105,7 +105,7 @@ namespace Zurnal.Domain.UseCase internal class UserLocalEntity { public string FIO { get; set; } - public Guid GroupID { get; set; } + public int GroupID { get; set; } public Guid Guid { get; set; } } }