This commit is contained in:
parent
e86bec8a7f
commit
4f7ef7ffb2
@ -72,9 +72,9 @@ public bool UpdateGroupById(int groupId, GroupDao updatedGroup)
|
||||
GroupDao.Name.Remove(group);
|
||||
}
|
||||
}
|
||||
public void UpdateGroup(GroupDao group)
|
||||
public GroupDao FindGroupById(int groupId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return AllGroup.FirstOrDefault(g => g.Id == groupId);
|
||||
}
|
||||
}
|
||||
}
|
@ -62,4 +62,18 @@ internal interface IGroupRepository
|
||||
group.GroupName = name;
|
||||
}
|
||||
}
|
||||
public bool UpdateUser(Guid userGuid, UserDao updatedUser)
|
||||
{
|
||||
if (updatedUser == null) throw new ArgumentNullException(nameof(updatedUser));
|
||||
|
||||
var user = AllGroup.SelectMany(g => g.Users).FirstOrDefault(u => u.UserGuid == userGuid);
|
||||
if (user != null)
|
||||
{
|
||||
user.FIO = updatedUser.FIO;
|
||||
user.GroupID = updatedUser.GroupID;
|
||||
user.Group = updatedUser.Group;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace Zurnal.Domain.UseCase
|
||||
|
||||
public bool RemoveGroupById(int groupID)
|
||||
{
|
||||
var group = _repositoryGroupImpl.GetGroupById(groupID);
|
||||
var group = _repositoryGroupImpl.FindGroupById(groupID);
|
||||
if (group == null)
|
||||
{
|
||||
return false;
|
||||
|
@ -30,16 +30,6 @@ namespace Zurnal.Domain.UseCase
|
||||
return _repositoryUserImpl.RemoveUserByGuid(userGuid);
|
||||
}
|
||||
|
||||
public UserDao UpdateUser(UserDao user, int groupId)
|
||||
{
|
||||
UserLocalEntity userLocalEntity = new UserLocalEntity { FIO = user.FIO, GroupID = groupId, Guid = user.UserGuid };
|
||||
UserLocalEntity? result = _repositoryUserImpl.UpdateUser(userLocalEntity);
|
||||
if (result == null) throw new Exception("Пользователь не обновлен.");
|
||||
GroupDao? group = GetAllGroups().FirstOrDefault(it => it.Id == result.GroupID);
|
||||
if (group == null) throw new Exception("Група не нфйдуна.");
|
||||
return new UserDao { FIO = user.FIO, UserGuid = user.UserGuid, Group = group, GroupID = group.Id };
|
||||
}
|
||||
|
||||
public IEnumerable<GroupDao> GetAllGroups()
|
||||
{
|
||||
return RepositoryGroupImpl.AllGroup;
|
||||
@ -66,11 +56,6 @@ namespace Zurnal.Domain.UseCase
|
||||
|
||||
public List<GroupDao> AllGroup => RepositoryGroupImpl.AllGroup.ToList();
|
||||
List<GroupDao> IGroupRepository.AllGroup => throw new NotImplementedException();
|
||||
|
||||
IEnumerable<System.Text.RegularExpressions.Group> IGroupRepository.AllGroups()
|
||||
{
|
||||
return (IEnumerable<System.Text.RegularExpressions.Group>)((IGroupRepository)_repositoryUserImpl).GetAllGroups();
|
||||
}
|
||||
internal class UserLocalEntity
|
||||
{
|
||||
public string FIO { get; set; }
|
||||
|
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Zurnal")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+34ff2ea057283cd78eb7b49bd26432b8fed15732")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e86bec8a7f833b7d641968f35cc2ebce20da3dc8")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Zurnal")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
0df9278f60a66dc8e6fa4dcbb3c724fa603d832d40511f5c21919f1d6dd33202
|
||||
91af4bd6b85cc028ddbbf62d14f2f440aae593b748896e98c6bba89005927b76
|
||||
|
@ -1 +1 @@
|
||||
284ebdeb3fab184734b12e3b8ba05c6bb9ebc0011e646a87edcca3ea143abd87
|
||||
132477173c8f0b9bd98b70bc6d28240502a0a14c41a11367b550c5913679e10c
|
||||
|
@ -1,9 +0,0 @@
|
||||
using Zurnal.UI;
|
||||
using Zurnal.Data.Repository;
|
||||
using Zurnal.Domain.UseCase;
|
||||
|
||||
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
|
||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
||||
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
||||
|
||||
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase);
|
Loading…
Reference in New Issue
Block a user