Vozmozno eto rabotaet

This commit is contained in:
Userok 2024-11-02 10:59:27 +03:00
parent 023f6a3f3f
commit fc4f46d1b7

View File

@ -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<Group> GetAllGroups()
{
return new List<Group>();
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; }
}
}