part of integrating opening csv files

This commit is contained in:
Dasha06 2024-12-17 12:13:12 +03:00
parent b8bf4628cc
commit 7022af564d
64 changed files with 215 additions and 21 deletions

View File

@ -8,12 +8,24 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Tmds.DBus.Protocol; using Tmds.DBus.Protocol;
namespace Presence.Desktop.ViewModels namespace Presence.Desktop.ViewModels
{ {
public class GroupViewModel : ViewModelBase, IRoutableViewModel public class GroupViewModel : ViewModelBase, IRoutableViewModel
{ {
public ICommand OpenFileDialog { get; }
public Interaction<string?, string?> SelectFileInteraction => _SelectFileInteraction;
public readonly Interaction<string?, string?> _SelectFileInteraction;
private string? _selectedFile;
public string? SelectedFile
{
get => _selectedFile;
set => this.RaiseAndSetIfChanged(ref _selectedFile, value);
}
private readonly List<GroupPresenter> _groupPresentersDataSource = new List<GroupPresenter>(); private readonly List<GroupPresenter> _groupPresentersDataSource = new List<GroupPresenter>();
private ObservableCollection<GroupPresenter> _groups; private ObservableCollection<GroupPresenter> _groups;
public ObservableCollection<GroupPresenter> Groups => _groups; public ObservableCollection<GroupPresenter> Groups => _groups;
@ -50,6 +62,8 @@ namespace Presence.Desktop.ViewModels
_groups = new ObservableCollection<GroupPresenter>(_groupPresentersDataSource); _groups = new ObservableCollection<GroupPresenter>(_groupPresentersDataSource);
_groupUseCase = groupUseCase; _groupUseCase = groupUseCase;
_SelectFileInteraction = new Interaction<string?, string?>();
OpenFileDialog = ReactiveCommand.CreateFromTask(SelectFile);
_users = new ObservableCollection<UserPresenter>(); _users = new ObservableCollection<UserPresenter>();
RefreshGroups(); RefreshGroups();
@ -98,5 +112,11 @@ namespace Presence.Desktop.ViewModels
} }
public string? UrlPathSegment { get; } public string? UrlPathSegment { get; }
public IScreen HostScreen { get; } public IScreen HostScreen { get; }
private async Task SelectFile()
{
Console.WriteLine("clock");
SelectedFile = await _SelectFileInteraction.Handle("Chose csv file");
}
} }
} }

View File

@ -27,7 +27,7 @@
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
<ComboBox/> <Button Width="100" Command="{Binding OpenFileDialog}"/>
<ComboBox/> <ComboBox/>
</StackPanel> </StackPanel>
<Border> <Border>
@ -35,7 +35,7 @@
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding Name}" Foreground="Black"/>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>

View File

@ -1 +1 @@
9bed0cd3c89dc88826b4309b09b8760dd6e18f10b2c8c30cedb93144a4b3ebad 8ff83d2bcb3cec6472dc66a2a69c5cfafb8cbd5996d3bbe796f44278fe829520

View File

@ -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+c690640f78e1f149f0f4dfceaba8f73ce93541f8")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b8bf4628cce91d7266a54ce8ba848e91ee1b2569")]
[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")]

View File

@ -1 +1 @@
8b882697ba5e9bf12ace9fba0b85c22dc0a2b8cbf33597d104c460fee549711b 4d609c065396d07151140e18cdb037e59080c5cb8458e11bf60ac5453325e867

Binary file not shown.

Binary file not shown.

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+c690640f78e1f149f0f4dfceaba8f73ce93541f8")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b8bf4628cce91d7266a54ce8ba848e91ee1b2569")]
[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 @@
c4b7c660d360501baf1f1942572f96b0c294069fdb2ffa46820e5f62689b2638 4bf58799393b54975cb249992c3335b53b5b1f8b9b387253b9f72465f1e756e4

View File

@ -34,10 +34,17 @@ namespace presence.data.Repository
public List<GroupDao> GetAllGroup() public List<GroupDao> GetAllGroup()
{ {
return _remoteDatabaseContext.Groups return _remoteDatabaseContext.Groups
.Include(g => g.User)
.Select(g => new GroupDao .Select(g => new GroupDao
{ {
Name = g.Name, Name = g.Name,
Id = g.Id Id = g.Id,
User = g.User.Select(u => new UserDao
{
FIO = u.FIO,
UserId = u.UserId,
GroupId = u.GroupId
}).ToList()
}).ToList(); }).ToList();
} }

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+c690640f78e1f149f0f4dfceaba8f73ce93541f8")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b8bf4628cce91d7266a54ce8ba848e91ee1b2569")]
[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 @@
6d0b8de6b931e9e0143fcb1b1cf9e324d3b41aace7681baad3b708e378bbf653 a83c002440d4fc833844f0ad9fb2316eca5384ff634b577accf58e96b177ac86

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,16 +2,15 @@ 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.Models.ResponseModels;
using presence.domain.Models; using presence.domain.Models;
namespace domain.UseCase namespace domain.UseCase
{ {
public interface IUserUseCase public interface IUserUseCase
{ {
List<User> GetAllUsers(); public IEnumerable<UserResponse> GetStudents();
bool RemoveUserById(int userId);
User GetUserById(int userId);
bool UpdateUserById(int userId, String fio, int groupId);
} }
} }

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+c690640f78e1f149f0f4dfceaba8f73ce93541f8")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b8bf4628cce91d7266a54ce8ba848e91ee1b2569")]
[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 @@
43afdf5708c755cbde2e76d819f2a123c0a982403109275bceb5be533c69e450 58b98f718e678f6a1418b7c4064bba479c5b66250df08cd49d82df8b5ba26dca

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using domain.Models.ResponseModels;
using domain.UseCase;
using presence.data.Repository;
namespace domain.Services
{
public class UserService : IUserUseCase
{
private readonly IUserRepository _userRepository;
public IEnumerable<UserResponse> GetStudents()
{
return _userRepository.GetAllUser().Select(
user => new UserResponse
{
Id = user.UserId,
FIO = user.FIO,
GroupId = user.GroupId,
Group = new GroupResponse
{
Name = user.Group.Name,
Id = user.Group.Id,
}
}
);
}
}
}

View File

@ -0,0 +1,34 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Presence.Desktop.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Presence.Desktop.Views.UserView"
x:DataType="vm:UserViewModel">
<Design.DataContext>
<vm:UserViewModel/>
</Design.DataContext>
<DockPanel Background="Azure">
<StackPanel DockPanel.Dock="Bottom">
<TextBlock Text="List ↑" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel
Spacing="10"
HorizontalAlignment="Center"
DockPanel.Dock="Top"
Orientation="Horizontal">
<TextBlock Text="Combobox ->"/>
<ComboBox ItemsSource="{Binding Users}" SelectedValue="{Binding SelectedUserItem}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox/>
<ComboBox/>
</StackPanel>
</DockPanel>
</UserControl>

View File

@ -0,0 +1,17 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using Presence.Desktop.ViewModels;
using ReactiveUI;
namespace Presence.Desktop.Views;
public partial class UserView : ReactiveUserControl<UserViewModel>
{
public UserView()
{
this.WhenActivated(disposables => { });
AvaloniaXamlLoader.Load(this);
}
}

View File

@ -0,0 +1,84 @@
using domain.UseCase;
using DynamicData;
using DynamicData.Binding;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Presence.Desktop.Models;
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Linq;
using Tmds.DBus.Protocol;
namespace Presence.Desktop.ViewModels
{
public class UserViewModel: ViewModelBase, IRoutableViewModel
{
private readonly List<UserPresenter> _userPresentersDataSource = new List<UserPresenter>();
private ObservableCollection<UserPresenter> _users;
public ObservableCollection<UserPresenter> Users => _users;
private IUserUseCase _userUseCase;
private UserPresenter? _selectedUserItem;
public UserPresenter? SelectedUserItem
{
get => _selectedUserItem;
set => this.RaiseAndSetIfChanged(ref _selectedUserItem, value);
}
public string? UrlPathSegment { get; }
public IScreen HostScreen { get; }
public UserViewModel(IUserUseCase userUseCase)
{
foreach (var user in userUseCase.GetStudents())
{
UserPresenter userPresenter = new UserPresenter
{
Id = user.Id,
Name = user.FIO,
Group = new GroupPresenter
{
Name = user.Group.Name,
Id = user.Group.Id,
}
};
_userPresentersDataSource.Add(userPresenter);
}
_users = new ObservableCollection<UserPresenter>(_userPresentersDataSource);
_userUseCase = userUseCase;
RefreshUsers();
this.WhenAnyValue(vm => vm.SelectedUserItem)
.Subscribe(_ =>
{
RefreshUsers();
});
}
private void RefreshUsers()
{
_userPresentersDataSource.Clear();
foreach (var user in _userUseCase.GetStudents())
{
UserPresenter userPresenter = new UserPresenter
{
Id = user.Id,
Name = user.FIO,
Group = new GroupPresenter
{
Name = user.Group.Name,
Id = user.Group.Id,
}
};
_userPresentersDataSource.Add(userPresenter);
}
_users = new ObservableCollection<UserPresenter>(_userPresentersDataSource);
}
}
}

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+c690640f78e1f149f0f4dfceaba8f73ce93541f8")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b8bf4628cce91d7266a54ce8ba848e91ee1b2569")]
[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 @@
dc964b6452494326efb17b5f11aa54a8134ee046ea9b8f4d5774ee6844209ae9 52221bf6c627d0a1f38ec9399dcd7b73938674fb1e29c05bd07d9c179faa01c4

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+c690640f78e1f149f0f4dfceaba8f73ce93541f8")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b8bf4628cce91d7266a54ce8ba848e91ee1b2569")]
[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 @@
527bdd839471066e3aa5070f0846ea8bc1eb12102df96e285b1a6055bb99ff1b a566caacf63689b16cb3406c30a83366cd1327afd2187d25ebbffca47b491f0b