context menu
This commit is contained in:
parent
9fb14f26f7
commit
80e6836fdd
@ -3,11 +3,20 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Presence.Desktop.Models
|
namespace Presence.Desktop.Models
|
||||||
{
|
{
|
||||||
public class UserPresenter
|
public class UserPresenter : ReactiveObject
|
||||||
{
|
{
|
||||||
|
private bool _isSelected;
|
||||||
|
|
||||||
|
public bool IsSelected
|
||||||
|
{
|
||||||
|
get => _isSelected;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _isSelected, value);
|
||||||
|
}
|
||||||
|
|
||||||
public Guid Guid { get; set; }
|
public Guid Guid { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public GroupPresenter Group { get; set; }
|
public GroupPresenter Group { get; set; }
|
||||||
|
@ -46,6 +46,7 @@ namespace Presence.Desktop.ViewModels
|
|||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> ButtonRemoveUsersByGroup { get; }
|
public ReactiveCommand<Unit, Unit> ButtonRemoveUsersByGroup { get; }
|
||||||
public ReactiveCommand<Unit, Unit> ImportStudentsCommand { get; }
|
public ReactiveCommand<Unit, Unit> ImportStudentsCommand { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> RemoveUsersContext { get; }
|
||||||
|
|
||||||
public GroupViewModel(IGroupUseCase groupUseCase, IUserUseCase userUseCase)
|
public GroupViewModel(IGroupUseCase groupUseCase, IUserUseCase userUseCase)
|
||||||
{
|
{
|
||||||
@ -71,6 +72,25 @@ namespace Presence.Desktop.ViewModels
|
|||||||
|
|
||||||
ButtonRemoveUsersByGroup = ReactiveCommand.Create(() => RemoveUsersByGroup());
|
ButtonRemoveUsersByGroup = ReactiveCommand.Create(() => RemoveUsersByGroup());
|
||||||
ImportStudentsCommand = ReactiveCommand.CreateFromTask(async () => await ImportStudents());
|
ImportStudentsCommand = ReactiveCommand.CreateFromTask(async () => await ImportStudents());
|
||||||
|
RemoveUsersContext = ReactiveCommand.Create(() => RemoveUsersByContextMenu());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveUsersByContextMenu(){
|
||||||
|
if (SelectedGroupItem == null || SelectedGroupItem.Id == null) return;
|
||||||
|
|
||||||
|
var selectedUsers = Users.Where(u => u.IsSelected).ToList();
|
||||||
|
|
||||||
|
foreach (var user in selectedUsers)
|
||||||
|
{
|
||||||
|
var isRemoved = _userUseCase.RemoveUserByFIOnGroup(user.Name, SelectedGroupItem.Id);
|
||||||
|
if (isRemoved)
|
||||||
|
{
|
||||||
|
Users.Remove(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshGroups();
|
||||||
|
SetUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUsers()
|
private void SetUsers()
|
||||||
@ -127,6 +147,7 @@ namespace Presence.Desktop.ViewModels
|
|||||||
SetUsers();
|
SetUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//import users
|
||||||
private async System.Threading.Tasks.Task ImportStudents()
|
private async System.Threading.Tasks.Task ImportStudents()
|
||||||
{
|
{
|
||||||
if (SelectedGroupItem == null || SelectedGroupItem.Id == null) return;
|
if (SelectedGroupItem == null || SelectedGroupItem.Id == null) return;
|
||||||
|
@ -45,10 +45,16 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Border>
|
<Border>
|
||||||
<ListBox Background="Bisque" ItemsSource="{Binding Users}">
|
<ListBox Background="Bisque" ItemsSource="{Binding Users}" SelectionMode="Multiple">
|
||||||
|
<ListBox.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Header="Remove" Command="{Binding RemoveUsersContext}"/>
|
||||||
|
</ContextMenu>
|
||||||
|
</ListBox.ContextMenu>
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<CheckBox IsChecked="{Binding IsSelected}" />
|
||||||
<TextBlock Text="{Binding Name}" FontSize="16" Foreground="Black"/>
|
<TextBlock Text="{Binding Name}" FontSize="16" Foreground="Black"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Presence.Desktop")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Presence.Desktop")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5a3b35edb803658a9e980fa84e334c956238d9a9")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9fb14f26f76520b93e2dffe32b9920452b1164eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Presence.Desktop")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Presence.Desktop")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Presence.Desktop")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Presence.Desktop")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
d952627ae154a47540761d913d76d1beb13d7e9e76c65e9ff752362c3bf11044
|
b7498df5d2206005112870d5c2c73b5108e5527e6c157c6bfa81adcb4e354c81
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("console_ui")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("console_ui")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cd14199d8f8882eb539425bae3cd58b140c7b374")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9fb14f26f76520b93e2dffe32b9920452b1164eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("console_ui")]
|
[assembly: System.Reflection.AssemblyProductAttribute("console_ui")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("console_ui")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("console_ui")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
51219e92f7d27c4d00e5b1e874dab7a450a0879becdee4165bf84b610fab9305
|
168f5efe473362e291e5e71f2ddeec86688eb46022542ef7888a19812808d8d7
|
||||||
|
Binary file not shown.
@ -9,6 +9,7 @@ namespace Demo.Data.Repository
|
|||||||
List<UserLocalEntity> GetUsersByGroupID(int groupID);
|
List<UserLocalEntity> GetUsersByGroupID(int groupID);
|
||||||
public UserLocalEntity? CreateUser(string FIO, string GroupName);
|
public UserLocalEntity? CreateUser(string FIO, string GroupName);
|
||||||
bool RemoveUserByGuid(Guid guid);
|
bool RemoveUserByGuid(Guid guid);
|
||||||
|
bool RemoveUserByFIOnGroup(string FIO, int groupID);
|
||||||
bool RemoveUsersByGroupID(int groupID);
|
bool RemoveUsersByGroupID(int groupID);
|
||||||
UserLocalEntity? UpdateUser(UserLocalEntity updatedUser);
|
UserLocalEntity? UpdateUser(UserLocalEntity updatedUser);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,13 @@ namespace Demo.Data.Repository
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool RemoveUserByFIOnGroup(string FIO, int groupID){
|
||||||
|
var userDAO = _remoteDatabaseContext.Users.FirstOrDefault(x => x.FIO == FIO && x.GroupID == groupID);
|
||||||
|
_remoteDatabaseContext.Users.Remove(userDAO);
|
||||||
|
_remoteDatabaseContext.SaveChanges();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public bool RemoveUsersByGroupID(int groupID)
|
public bool RemoveUsersByGroupID(int groupID)
|
||||||
{
|
{
|
||||||
var users = GetUsersByGroupID(groupID);
|
var users = GetUsersByGroupID(groupID);
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("data")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("data")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5a3b35edb803658a9e980fa84e334c956238d9a9")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9fb14f26f76520b93e2dffe32b9920452b1164eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("data")]
|
[assembly: System.Reflection.AssemblyProductAttribute("data")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("data")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("data")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
59db47dd6079fbc3eeedc9d89e5043d653f86627d896b473ee1563f96c012ce1
|
c72b092daa6ba175d3015381913771c1e175cbd23d956f6f46fe3a4f2b74b730
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,6 +8,7 @@ namespace Demo.Domain.UseCase
|
|||||||
bool CreateUser(User user);
|
bool CreateUser(User user);
|
||||||
bool CreateUserUI(string FIO, string GroupName);
|
bool CreateUserUI(string FIO, string GroupName);
|
||||||
bool RemoveUserByGuid(Guid userGuid);
|
bool RemoveUserByGuid(Guid userGuid);
|
||||||
|
bool RemoveUserByFIOnGroup(string FIO, int groupID);
|
||||||
User UpdateUser(User user);
|
User UpdateUser(User user);
|
||||||
User GetUserByGuid(Guid userGuid);
|
User GetUserByGuid(Guid userGuid);
|
||||||
List<User> GetUsersByGroupID(int groupID);
|
List<User> GetUsersByGroupID(int groupID);
|
||||||
|
@ -76,6 +76,10 @@ namespace Demo.Domain.UseCase
|
|||||||
return _repositoryUserImpl.RemoveUserByGuid(userGuid);
|
return _repositoryUserImpl.RemoveUserByGuid(userGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool RemoveUserByFIOnGroup(string FIO, int groupID) {
|
||||||
|
return _repositoryUserImpl.RemoveUserByFIOnGroup(FIO, groupID);
|
||||||
|
}
|
||||||
|
|
||||||
public User UpdateUser(User user)
|
public User UpdateUser(User user)
|
||||||
{
|
{
|
||||||
UserLocalEntity userLocalEntity = new UserLocalEntity
|
UserLocalEntity userLocalEntity = new UserLocalEntity
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("domain")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("domain")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5a3b35edb803658a9e980fa84e334c956238d9a9")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9fb14f26f76520b93e2dffe32b9920452b1164eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("domain")]
|
[assembly: System.Reflection.AssemblyProductAttribute("domain")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("domain")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("domain")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
74684369dd334aa6def5609e908e0313868255d5ce0e40c2086e66367b6a5e8e
|
a090e784cd672ac7f4d063a1614d0b2085d1bef552d25f58907fdd2eb3060720
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("presence_api")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("presence_api")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cd14199d8f8882eb539425bae3cd58b140c7b374")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9fb14f26f76520b93e2dffe32b9920452b1164eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("presence_api")]
|
[assembly: System.Reflection.AssemblyProductAttribute("presence_api")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("presence_api")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("presence_api")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
cdb6b5133bde93b1586d7932ccbb76ae9ea6878c6857ff99e7fdf6b01f268cf2
|
7c4d0c2c4bfbba3e9226dc05c7c6db1bcce4df4ad872df73c45f5e0b076c25bd
|
||||||
|
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ui")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ui")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cd14199d8f8882eb539425bae3cd58b140c7b374")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9fb14f26f76520b93e2dffe32b9920452b1164eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ui")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ui")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ui")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ui")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
fef66748500a16e29f0a17a78c8a1c71cb47b72d1a0688ea26826661405a52af
|
e2f28b5b9ef339961c4e1f85cf1fc465d19791b59a3da4607c5a8ef82054440f
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user