now changing screens work
This commit is contained in:
parent
38cf16c345
commit
eadf72b512
@ -22,12 +22,17 @@ namespace Presence.Desktop.DI
|
||||
public static void AddCommonService(this IServiceCollection collection) {
|
||||
collection
|
||||
.AddDbContext<RemoteDataBaseContext>()
|
||||
.AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>()
|
||||
.AddSingleton<IUserRepository, SQLUserRepositoryImpl>()
|
||||
.AddTransient<GroupUseCase>()
|
||||
|
||||
.AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>()
|
||||
.AddSingleton<IUserRepository, SQLUserRepositoryImpl>()
|
||||
.AddSingleton<IPresenceRepository, SQLPresenceRepositoryImpl>()
|
||||
.AddSingleton<PresenceUseCase>()
|
||||
.AddSingleton<UserUseCase>()
|
||||
.AddTransient<GroupUseCase>()
|
||||
.AddTransient<IGroupUseCase, GroupService>()
|
||||
.AddTransient<GroupViewModel>()
|
||||
.AddTransient<PresenceViewModel>();
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ namespace Presence.Desktop.Models
|
||||
{
|
||||
public class PresencePresenter
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public int ClassNumber { get; set; }
|
||||
public bool IsAttendence { get; set; }
|
||||
|
@ -14,13 +14,18 @@ using Avalonia.Controls.Selection;
|
||||
using presence.data.RemoteData.RemoteDataBase;
|
||||
using presence.data.Repository;
|
||||
using presence.domain.UseCase;
|
||||
using System.Reactive;
|
||||
using Splat;
|
||||
|
||||
namespace Presence.Desktop.ViewModels
|
||||
{
|
||||
public class GroupViewModel : ViewModelBase, IRoutableViewModel
|
||||
{
|
||||
private readonly RemoteDataBaseContext _remoteDatabaseContext;
|
||||
public ICommand OpenFileDialog { get; }
|
||||
|
||||
public string? UrlPathSegment { get; }
|
||||
public IScreen HostScreen { get; }
|
||||
private readonly PresenceUseCase _presenceUseCase;
|
||||
public ICommand OpenFileDialog { get; }
|
||||
public Interaction<string?, string?> SelectFileInteraction => _SelectFileInteraction;
|
||||
public readonly Interaction<string?, string?> _SelectFileInteraction;
|
||||
private string? _selectedFile;
|
||||
@ -52,12 +57,14 @@ namespace Presence.Desktop.ViewModels
|
||||
public ICommand RemoveUserCommand { get; }
|
||||
public ICommand EditUserCommand { get; }
|
||||
public ICommand RemoveAllSelectedCommand { get; }
|
||||
public ICommand NavigateToPresenceCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> NavigateToPresenceCommand { get; }
|
||||
|
||||
public GroupViewModel(IGroupUseCase groupUseCase, RemoteDataBaseContext remoteDataBaseContext)
|
||||
public GroupViewModel(IGroupUseCase groupUseCase, PresenceUseCase presenceUseCase, IScreen? screen = null)
|
||||
{
|
||||
HostScreen = screen ?? Locator.Current.GetService<IScreen>()!;
|
||||
_groupUseCase = groupUseCase;
|
||||
_remoteDatabaseContext = remoteDataBaseContext;
|
||||
_presenceUseCase = presenceUseCase;
|
||||
|
||||
|
||||
_SelectFileInteraction = new Interaction<string?, string?>();
|
||||
OpenFileDialog = ReactiveCommand.CreateFromTask(SelectFile);
|
||||
@ -95,7 +102,6 @@ namespace Presence.Desktop.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void RefreshGroups()
|
||||
{
|
||||
_groupPresentersDataSource.Clear();
|
||||
@ -123,9 +129,6 @@ namespace Presence.Desktop.ViewModels
|
||||
MultipleSelected = Selection.SelectedItems.Count > 1;
|
||||
}
|
||||
|
||||
public string? UrlPathSegment { get; }
|
||||
public IScreen HostScreen { get; }
|
||||
|
||||
private async Task SelectFile()
|
||||
{
|
||||
Console.WriteLine("clock");
|
||||
@ -164,10 +167,12 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
private void NavigateToPresence()
|
||||
{
|
||||
var groupRepository = new SQLGroupRepositoryImpl(_remoteDatabaseContext);
|
||||
var groupRepository = new SQLGroupRepositoryImpl(new RemoteDataBaseContext());
|
||||
var groupUseCase = new GroupUseCase(groupRepository);
|
||||
|
||||
HostScreen.Router.Navigate.Execute(new PresenceViewModel(groupUseCase));
|
||||
// Добавляем логику навигации к PresenceViewModel
|
||||
var presenceViewModel = new PresenceViewModel(groupUseCase, _presenceUseCase);
|
||||
HostScreen.Router.Navigate.Execute(presenceViewModel);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using domain.UseCase;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using presence.data.RemoteData.RemoteDataBase;
|
||||
using presence.domain.UseCase;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Presence.Desktop.ViewModels
|
||||
@ -11,10 +14,12 @@ namespace Presence.Desktop.ViewModels
|
||||
{
|
||||
public RoutingState Router { get; } = new RoutingState();
|
||||
|
||||
public MainWindowViewModel(IServiceProvider serviceProvider)
|
||||
{
|
||||
var groupViewModel = serviceProvider.GetRequiredService<GroupViewModel>();
|
||||
Router.Navigate.Execute(groupViewModel);
|
||||
}
|
||||
public MainWindowViewModel(IServiceProvider serviceProvider)
|
||||
{
|
||||
var iGroupUseCase = serviceProvider.GetRequiredService<IGroupUseCase>();
|
||||
var presenceUseCase = serviceProvider.GetRequiredService<PresenceUseCase>();
|
||||
|
||||
Router.Navigate.Execute(new GroupViewModel(iGroupUseCase, presenceUseCase, this));
|
||||
}
|
||||
}
|
||||
}
|
@ -34,8 +34,8 @@ namespace Presence.Desktop.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private DateOnly? _selectedDate;
|
||||
public DateOnly? SelectedDate
|
||||
private DateTime? _selectedDate;
|
||||
public DateTime? SelectedDate
|
||||
{
|
||||
get => _selectedDate;
|
||||
set
|
||||
@ -47,14 +47,20 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
public ReactiveCommand<Unit, Unit> NavigateBackCommand { get; }
|
||||
|
||||
public PresenceViewModel(GroupUseCase groupUseCase)
|
||||
public PresenceViewModel(GroupUseCase groupUseCase, PresenceUseCase presenceUseCase)
|
||||
{
|
||||
_groupUseCase = groupUseCase;
|
||||
|
||||
_presenceUseCase = presenceUseCase;
|
||||
|
||||
|
||||
NavigateBackCommand = ReactiveCommand.Create(() => { });
|
||||
|
||||
LoadGroups();
|
||||
this.WhenAnyValue(vm => vm.SelectedGroup)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
LoadGroups();
|
||||
});
|
||||
}
|
||||
|
||||
private void LoadGroups()
|
||||
@ -74,7 +80,7 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
private void FilterAttendanceRecords()
|
||||
{
|
||||
if (SelectedGroup == null || SelectedDate == null)
|
||||
if (SelectedGroup == null)
|
||||
{
|
||||
AttendanceRecords.Clear();
|
||||
return;
|
||||
@ -82,13 +88,14 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
var records = _presenceUseCase.GetPresenceByGroupAndDate(
|
||||
SelectedGroup.Id,
|
||||
SelectedDate.Value);
|
||||
DateOnly.FromDateTime(SelectedDate.Value));
|
||||
|
||||
AttendanceRecords.Clear();
|
||||
foreach (var record in records)
|
||||
{
|
||||
AttendanceRecords.Add(new PresencePresenter
|
||||
{
|
||||
Id = record.Id,
|
||||
Date = record.Date,
|
||||
ClassNumber = record.ClassNumber,
|
||||
IsAttendence = record.IsAttendence,
|
||||
|
@ -7,7 +7,7 @@
|
||||
x:Class="Presence.Desktop.Views.PresenceView"
|
||||
x:DataType="vm:PresenceViewModel">
|
||||
|
||||
<Grid RowDefinitions="Auto, Auto, *, Auto" Margin="10">
|
||||
<Grid RowDefinitions="Auto, Auto, *, Auto" Margin="10" Background="Aquamarine">
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Spacing="10">
|
||||
<!-- Выбор группы -->
|
||||
<ComboBox ItemsSource="{Binding Groups}" SelectedItem="{Binding SelectedGroup}" Width="200" PlaceholderText="Выберите группу">
|
||||
@ -25,7 +25,7 @@
|
||||
<!-- Таблица с посещаемостью -->
|
||||
<DataGrid Grid.Row="2" AutoGenerateColumns="False" ItemsSource="{Binding AttendanceRecords}" CanUserSortColumns="True">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Дата" Binding="{Binding Date}" />
|
||||
<DataGridTextColumn Header="Дата" Binding="{Binding Date}" Foreground="Black"/>
|
||||
<DataGridTextColumn Header="Номер урока" Binding="{Binding ClassNumber}" />
|
||||
<DataGridTextColumn Header="ФИО" Binding="{Binding User.Name}" />
|
||||
|
||||
|
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.
@ -1 +1 @@
|
||||
9bed0cd3c89dc88826b4309b09b8760dd6e18f10b2c8c30cedb93144a4b3ebad
|
||||
8ff83d2bcb3cec6472dc66a2a69c5cfafb8cbd5996d3bbe796f44278fe829520
|
||||
|
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Presence.Desktop")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d902b6f481ae89f72a8bbdfe147247c3696808e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Presence.Desktop")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Presence.Desktop")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
48554ad8782293b7cc2f242624ddfa361309e094aa6ac7b85c8ebaf337a70f40
|
||||
a55713119259355cce81a2db571720adcd3acb7bc2009903ebf5dba4fbc71e3d
|
||||
|
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.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d902b6f481ae89f72a8bbdfe147247c3696808e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("console_ui")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("console_ui")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
b1eb225ffe5f3f4f77eb6e686327399e3b9adee1531fc1962f9f2de9f983cf57
|
||||
b646cd9abdfaed63b2c066937a57ee292758ed891f5a7c5830756fb43e02e2ee
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("data")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d902b6f481ae89f72a8bbdfe147247c3696808e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("data")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("data")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
491a118ec5543e51089962ed9bcdfa5b8cf88b30968e339c3fc43e732215e55c
|
||||
c7ce76312ceb7b78b59ab7c078914f3d4e8a1907cd4153da36c3432f01ff593b
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace presence.domain.Models
|
||||
{
|
||||
public class Presence{
|
||||
public int Id { get; set;}
|
||||
public required DateOnly Date {get; set;}
|
||||
public int ClassNumber {get; set;}
|
||||
public bool IsAttendence {get; set;}
|
||||
|
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.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d902b6f481ae89f72a8bbdfe147247c3696808e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("domain")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("domain")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
3879d5ba26c2c5c5a09dc7d172821c4e08e4aefc11c2344ccecf9e4847449c91
|
||||
bdff4fbeccb346e2cf4a8dfcc1d45f5250114d880df44801d9b74b9d8ac7603a
|
||||
|
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.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d902b6f481ae89f72a8bbdfe147247c3696808e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("presence_api")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("presence_api")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
312fc1680bcd1ec62bf371b791280808df779a4ccf1606d84ea5fb3bb5f77969
|
||||
1e75923e7041345eb2f77db14fdab7a996030a49a36f5debb66b329692ed2bc1
|
||||
|
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ui")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d902b6f481ae89f72a8bbdfe147247c3696808e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("ui")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("ui")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
519394075c67a7ab9c81664396c682f0d50cbaab063eb07cdd1c12824d46a3ff
|
||||
6b630ab98cc90f908ad3afc0ecce6478a4e69213272d76fa17d581b71e586852
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user