now changing screens work

This commit is contained in:
Dasha06 2024-12-23 14:56:27 +03:00
parent 38cf16c345
commit eadf72b512
53 changed files with 65 additions and 41 deletions

View File

@ -22,12 +22,17 @@ namespace Presence.Desktop.DI
public static void AddCommonService(this IServiceCollection collection) { public static void AddCommonService(this IServiceCollection collection) {
collection collection
.AddDbContext<RemoteDataBaseContext>() .AddDbContext<RemoteDataBaseContext>()
.AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>() .AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>()
.AddSingleton<IUserRepository, SQLUserRepositoryImpl>() .AddSingleton<IUserRepository, SQLUserRepositoryImpl>()
.AddSingleton<IPresenceRepository, SQLPresenceRepositoryImpl>()
.AddSingleton<PresenceUseCase>()
.AddSingleton<UserUseCase>()
.AddTransient<GroupUseCase>() .AddTransient<GroupUseCase>()
.AddTransient<IGroupUseCase, GroupService>() .AddTransient<IGroupUseCase, GroupService>()
.AddTransient<GroupViewModel>() .AddTransient<GroupViewModel>()
.AddTransient<PresenceViewModel>(); .AddTransient<PresenceViewModel>();
;
} }
} }
} }

View File

@ -8,6 +8,7 @@ namespace Presence.Desktop.Models
{ {
public class PresencePresenter public class PresencePresenter
{ {
public int Id { get; set; }
public DateOnly Date { get; set; } public DateOnly Date { get; set; }
public int ClassNumber { get; set; } public int ClassNumber { get; set; }
public bool IsAttendence { get; set; } public bool IsAttendence { get; set; }

View File

@ -14,12 +14,17 @@ using Avalonia.Controls.Selection;
using presence.data.RemoteData.RemoteDataBase; using presence.data.RemoteData.RemoteDataBase;
using presence.data.Repository; using presence.data.Repository;
using presence.domain.UseCase; using presence.domain.UseCase;
using System.Reactive;
using Splat;
namespace Presence.Desktop.ViewModels namespace Presence.Desktop.ViewModels
{ {
public class GroupViewModel : ViewModelBase, IRoutableViewModel public class GroupViewModel : ViewModelBase, IRoutableViewModel
{ {
private readonly RemoteDataBaseContext _remoteDatabaseContext;
public string? UrlPathSegment { get; }
public IScreen HostScreen { get; }
private readonly PresenceUseCase _presenceUseCase;
public ICommand OpenFileDialog { get; } public ICommand OpenFileDialog { get; }
public Interaction<string?, string?> SelectFileInteraction => _SelectFileInteraction; public Interaction<string?, string?> SelectFileInteraction => _SelectFileInteraction;
public readonly Interaction<string?, string?> _SelectFileInteraction; public readonly Interaction<string?, string?> _SelectFileInteraction;
@ -52,12 +57,14 @@ namespace Presence.Desktop.ViewModels
public ICommand RemoveUserCommand { get; } public ICommand RemoveUserCommand { get; }
public ICommand EditUserCommand { get; } public ICommand EditUserCommand { get; }
public ICommand RemoveAllSelectedCommand { 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; _groupUseCase = groupUseCase;
_remoteDatabaseContext = remoteDataBaseContext; _presenceUseCase = presenceUseCase;
_SelectFileInteraction = new Interaction<string?, string?>(); _SelectFileInteraction = new Interaction<string?, string?>();
OpenFileDialog = ReactiveCommand.CreateFromTask(SelectFile); OpenFileDialog = ReactiveCommand.CreateFromTask(SelectFile);
@ -95,7 +102,6 @@ namespace Presence.Desktop.ViewModels
} }
} }
private void RefreshGroups() private void RefreshGroups()
{ {
_groupPresentersDataSource.Clear(); _groupPresentersDataSource.Clear();
@ -123,9 +129,6 @@ namespace Presence.Desktop.ViewModels
MultipleSelected = Selection.SelectedItems.Count > 1; MultipleSelected = Selection.SelectedItems.Count > 1;
} }
public string? UrlPathSegment { get; }
public IScreen HostScreen { get; }
private async Task SelectFile() private async Task SelectFile()
{ {
Console.WriteLine("clock"); Console.WriteLine("clock");
@ -164,10 +167,12 @@ namespace Presence.Desktop.ViewModels
private void NavigateToPresence() private void NavigateToPresence()
{ {
var groupRepository = new SQLGroupRepositoryImpl(_remoteDatabaseContext); var groupRepository = new SQLGroupRepositoryImpl(new RemoteDataBaseContext());
var groupUseCase = new GroupUseCase(groupRepository); var groupUseCase = new GroupUseCase(groupRepository);
HostScreen.Router.Navigate.Execute(new PresenceViewModel(groupUseCase)); // Добавляем логику навигации к PresenceViewModel
var presenceViewModel = new PresenceViewModel(groupUseCase, _presenceUseCase);
HostScreen.Router.Navigate.Execute(presenceViewModel);
} }
} }
} }

View File

@ -2,7 +2,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using domain.UseCase;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using presence.data.RemoteData.RemoteDataBase;
using presence.domain.UseCase;
using ReactiveUI; using ReactiveUI;
namespace Presence.Desktop.ViewModels namespace Presence.Desktop.ViewModels
@ -13,8 +16,10 @@ namespace Presence.Desktop.ViewModels
public MainWindowViewModel(IServiceProvider serviceProvider) public MainWindowViewModel(IServiceProvider serviceProvider)
{ {
var groupViewModel = serviceProvider.GetRequiredService<GroupViewModel>(); var iGroupUseCase = serviceProvider.GetRequiredService<IGroupUseCase>();
Router.Navigate.Execute(groupViewModel); var presenceUseCase = serviceProvider.GetRequiredService<PresenceUseCase>();
Router.Navigate.Execute(new GroupViewModel(iGroupUseCase, presenceUseCase, this));
} }
} }
} }

View File

@ -34,8 +34,8 @@ namespace Presence.Desktop.ViewModels
} }
} }
private DateOnly? _selectedDate; private DateTime? _selectedDate;
public DateOnly? SelectedDate public DateTime? SelectedDate
{ {
get => _selectedDate; get => _selectedDate;
set set
@ -47,14 +47,20 @@ namespace Presence.Desktop.ViewModels
public ReactiveCommand<Unit, Unit> NavigateBackCommand { get; } public ReactiveCommand<Unit, Unit> NavigateBackCommand { get; }
public PresenceViewModel(GroupUseCase groupUseCase) public PresenceViewModel(GroupUseCase groupUseCase, PresenceUseCase presenceUseCase)
{ {
_groupUseCase = groupUseCase; _groupUseCase = groupUseCase;
_presenceUseCase = presenceUseCase;
NavigateBackCommand = ReactiveCommand.Create(() => { }); NavigateBackCommand = ReactiveCommand.Create(() => { });
this.WhenAnyValue(vm => vm.SelectedGroup)
.Subscribe(_ =>
{
LoadGroups(); LoadGroups();
});
} }
private void LoadGroups() private void LoadGroups()
@ -74,7 +80,7 @@ namespace Presence.Desktop.ViewModels
private void FilterAttendanceRecords() private void FilterAttendanceRecords()
{ {
if (SelectedGroup == null || SelectedDate == null) if (SelectedGroup == null)
{ {
AttendanceRecords.Clear(); AttendanceRecords.Clear();
return; return;
@ -82,13 +88,14 @@ namespace Presence.Desktop.ViewModels
var records = _presenceUseCase.GetPresenceByGroupAndDate( var records = _presenceUseCase.GetPresenceByGroupAndDate(
SelectedGroup.Id, SelectedGroup.Id,
SelectedDate.Value); DateOnly.FromDateTime(SelectedDate.Value));
AttendanceRecords.Clear(); AttendanceRecords.Clear();
foreach (var record in records) foreach (var record in records)
{ {
AttendanceRecords.Add(new PresencePresenter AttendanceRecords.Add(new PresencePresenter
{ {
Id = record.Id,
Date = record.Date, Date = record.Date,
ClassNumber = record.ClassNumber, ClassNumber = record.ClassNumber,
IsAttendence = record.IsAttendence, IsAttendence = record.IsAttendence,

View File

@ -7,7 +7,7 @@
x:Class="Presence.Desktop.Views.PresenceView" x:Class="Presence.Desktop.Views.PresenceView"
x:DataType="vm:PresenceViewModel"> 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"> <StackPanel Orientation="Horizontal" Grid.Row="0" Spacing="10">
<!-- Выбор группы --> <!-- Выбор группы -->
<ComboBox ItemsSource="{Binding Groups}" SelectedItem="{Binding SelectedGroup}" Width="200" PlaceholderText="Выберите группу"> <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 Grid.Row="2" AutoGenerateColumns="False" ItemsSource="{Binding AttendanceRecords}" CanUserSortColumns="True">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="Дата" Binding="{Binding Date}" /> <DataGridTextColumn Header="Дата" Binding="{Binding Date}" Foreground="Black"/>
<DataGridTextColumn Header="Номер урока" Binding="{Binding ClassNumber}" /> <DataGridTextColumn Header="Номер урока" Binding="{Binding ClassNumber}" />
<DataGridTextColumn Header="ФИО" Binding="{Binding User.Name}" /> <DataGridTextColumn Header="ФИО" Binding="{Binding User.Name}" />

View File

@ -1 +1 @@
9bed0cd3c89dc88826b4309b09b8760dd6e18f10b2c8c30cedb93144a4b3ebad 8ff83d2bcb3cec6472dc66a2a69c5cfafb8cbd5996d3bbe796f44278fe829520

View File

@ -13,10 +13,10 @@ 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+0d902b6f481ae89f72a8bbdfe147247c3696808e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
[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")]
// Generated by the MSBuild WriteCodeFragment class. // Создано классом WriteCodeFragment MSBuild.

View File

@ -1 +1 @@
48554ad8782293b7cc2f242624ddfa361309e094aa6ac7b85c8ebaf337a70f40 a55713119259355cce81a2db571720adcd3acb7bc2009903ebf5dba4fbc71e3d

View File

@ -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+0d902b6f481ae89f72a8bbdfe147247c3696808e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
[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")]

View File

@ -1 +1 @@
b1eb225ffe5f3f4f77eb6e686327399e3b9adee1531fc1962f9f2de9f983cf57 b646cd9abdfaed63b2c066937a57ee292758ed891f5a7c5830756fb43e02e2ee

Binary file not shown.

Binary file not shown.

View File

@ -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+0d902b6f481ae89f72a8bbdfe147247c3696808e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
[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")]

View File

@ -1 +1 @@
491a118ec5543e51089962ed9bcdfa5b8cf88b30968e339c3fc43e732215e55c c7ce76312ceb7b78b59ab7c078914f3d4e8a1907cd4153da36c3432f01ff593b

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
namespace presence.domain.Models namespace presence.domain.Models
{ {
public class Presence{ public class Presence{
public int Id { get; set;}
public required DateOnly Date {get; set;} public required DateOnly Date {get; set;}
public int ClassNumber {get; set;} public int ClassNumber {get; set;}
public bool IsAttendence {get; set;} public bool IsAttendence {get; set;}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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+0d902b6f481ae89f72a8bbdfe147247c3696808e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
[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")]

View File

@ -1 +1 @@
3879d5ba26c2c5c5a09dc7d172821c4e08e4aefc11c2344ccecf9e4847449c91 bdff4fbeccb346e2cf4a8dfcc1d45f5250114d880df44801d9b74b9d8ac7603a

Binary file not shown.

Binary file not shown.

View File

@ -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+0d902b6f481ae89f72a8bbdfe147247c3696808e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
[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")]

View File

@ -1 +1 @@
312fc1680bcd1ec62bf371b791280808df779a4ccf1606d84ea5fb3bb5f77969 1e75923e7041345eb2f77db14fdab7a996030a49a36f5debb66b329692ed2bc1

View File

@ -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+0d902b6f481ae89f72a8bbdfe147247c3696808e")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
[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")]

View File

@ -1 +1 @@
519394075c67a7ab9c81664396c682f0d50cbaab063eb07cdd1c12824d46a3ff 6b630ab98cc90f908ad3afc0ecce6478a4e69213272d76fa17d581b71e586852