set refresh changes
This commit is contained in:
parent
e1053ae6d7
commit
e8e6221200
@ -1,4 +1,5 @@
|
|||||||
using domain.Service;
|
using domain.Request;
|
||||||
|
using domain.Service;
|
||||||
using domain.UseCase;
|
using domain.UseCase;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Presence.Api.Response;
|
using Presence.Api.Response;
|
||||||
@ -33,5 +34,12 @@ namespace Presence.Api.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("/admin/{groupId}/students")]
|
||||||
|
public void AddGroup(int groupId, [FromBody] AddGroupRequest addGroupRequest)
|
||||||
|
{
|
||||||
|
Console.WriteLine(groupId);
|
||||||
|
_groupService.AddGroup(addGroupRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,38 @@ namespace Presence.Desktop.ViewModels
|
|||||||
private GroupPresenter? _selectedGroupItem;
|
private GroupPresenter? _selectedGroupItem;
|
||||||
|
|
||||||
|
|
||||||
|
private IGroupUseCase _groupUseCase;
|
||||||
public ObservableCollection<UserPresenter> Users { get => _users;}
|
public ObservableCollection<UserPresenter> Users { get => _users;}
|
||||||
public ObservableCollection<UserPresenter> _users;
|
public ObservableCollection<UserPresenter> _users;
|
||||||
public GroupViewModel(IGroupUseCase groupUseCase)
|
public GroupViewModel(IGroupUseCase groupUseCase)
|
||||||
{
|
{
|
||||||
foreach (var item in groupUseCase.GetGroupsWithStudents())
|
_groupUseCase = groupUseCase;
|
||||||
|
_users = new ObservableCollection<UserPresenter>();
|
||||||
|
RefreshGroups();
|
||||||
|
this.WhenAnyValue(vm => vm.SelectedGroupItem)
|
||||||
|
.Subscribe(_ =>
|
||||||
|
{ RefreshGroups();
|
||||||
|
SetUsers();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetUsers()
|
||||||
|
{
|
||||||
|
if(SelectedGroupItem == null) return;
|
||||||
|
Users.Clear();
|
||||||
|
var group = _groups.First(it => it.Id == SelectedGroupItem.Id);
|
||||||
|
if(group.users == null) return;
|
||||||
|
foreach (var item in group.users)
|
||||||
|
{
|
||||||
|
Users.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshGroups()
|
||||||
|
{
|
||||||
|
_groupPresentersDataSource.Clear();
|
||||||
|
foreach (var item in _groupUseCase.GetGroupsWithStudents())
|
||||||
{
|
{
|
||||||
GroupPresenter groupPresenter = new GroupPresenter
|
GroupPresenter groupPresenter = new GroupPresenter
|
||||||
{
|
{
|
||||||
@ -47,25 +73,7 @@ namespace Presence.Desktop.ViewModels
|
|||||||
_groupPresentersDataSource.Add(groupPresenter);
|
_groupPresentersDataSource.Add(groupPresenter);
|
||||||
}
|
}
|
||||||
_groups = new ObservableCollection<GroupPresenter>(_groupPresentersDataSource);
|
_groups = new ObservableCollection<GroupPresenter>(_groupPresentersDataSource);
|
||||||
|
|
||||||
_users = new ObservableCollection<UserPresenter>();
|
|
||||||
|
|
||||||
this.WhenAnyValue(vm => vm.SelectedGroupItem)
|
|
||||||
.Subscribe(_ => SetUsers());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUsers()
|
|
||||||
{
|
|
||||||
if(SelectedGroupItem == null) return;
|
|
||||||
if (SelectedGroupItem.users == null) return;
|
|
||||||
Users.Clear();
|
|
||||||
foreach (var item in SelectedGroupItem.users)
|
|
||||||
{
|
|
||||||
Users.Add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string? UrlPathSegment { get; }
|
public string? UrlPathSegment { get; }
|
||||||
public IScreen HostScreen { get; }
|
public IScreen HostScreen { get; }
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:app="clr-namespace:Presence.Desktop"
|
xmlns:app="clr-namespace:Presence.Desktop"
|
||||||
|
Loading…
Reference in New Issue
Block a user