Userhez is lehet már NFC kódot rendelni

This commit is contained in:
2025-04-15 19:42:48 +02:00
parent c51ee750f9
commit e151590860
19 changed files with 243 additions and 123 deletions
@@ -17,18 +17,21 @@
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
<StackLayout>
<Label Text="{Binding ShortName}" FontSize="16" FontAttributes="Bold" />
<Label Text="{Binding Code}" FontSize="14" />
<HorizontalStackLayout HorizontalOptions="End">
<Button Text="Edit" Margin="5,0,0,0"
Command="{Binding BindingContext.EditCommand, Source={x:Reference UsersList}}"
CommandParameter="{Binding .}" />
<Button Text="Pair" Margin="5,0,0,0"
Command="{Binding BindingContext.PairCommand, Source={x:Reference UsersList}}"
CommandParameter="{Binding .}" />
<Grid ColumnDefinitions="*,Auto">
<StackLayout Grid.Column="0" Spacing="2">
<Label Text="{Binding FullName}" FontSize="16" FontAttributes="Bold" />
<Label Text="{Binding NFCCode}" FontSize="14" />
</StackLayout>
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="5">
<Button Text="Párosítás" Margin="5,0,0,0"
HeightRequest="50"
MaximumHeightRequest="50"
WidthRequest="120"
MaximumWidthRequest="120"
Command="{Binding BindingContext.PairCommand, Source={x:Reference UsersList}}"
CommandParameter="{Binding .}" />
</HorizontalStackLayout>
</StackLayout>
</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
@@ -9,12 +9,13 @@ public partial class UsersPage : ContentPage
{
private readonly IUserService _userService;
private readonly ISyncService _syncService;
public UsersPage()
{
InitializeComponent();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
}
public ICommand RefreshCommand { get; set; }
@@ -25,7 +26,7 @@ public partial class UsersPage : ContentPage
{
base.OnAppearing();
RefreshCommand = new Command(async () => await LoadUsers());
PairCommand = new Command<UserDTO>(OnPairItem);
PairCommand = new Command<MobileUserDTO>(OnPairItem);
BindingContext = this;
await LoadUsers();
@@ -35,12 +36,12 @@ public partial class UsersPage : ContentPage
{
IsRefreshing = true;
//await _syncService.SyncDatas();
//UsersList.ItemsSource = await _userService.GetAllUserAsync().Result.Data;
UsersList.ItemsSource = await _userService.GetAllMobileUserAsync();
IsRefreshing = false;
OnPropertyChanged(nameof(IsRefreshing));
}
private async void OnPairItem(UserDTO UserDTO)
private async void OnPairItem(MobileUserDTO mobileUserDTO)
{
var UserCode = await NFCWaiter.ShowModalAsync();
if (!string.IsNullOrEmpty(UserCode))
@@ -49,10 +50,11 @@ public partial class UsersPage : ContentPage
{
await Navigation.PopModalAsync();
}
if (UserDTO != null)
if (mobileUserDTO != null)
{
//UserDTO.Code = UserCode;
//await _baseStockService.UpdateUser(UserDTO);
mobileUserDTO.NFCCode = UserCode;
await _userService.UpdateCheckPoint(mobileUserDTO);
await LoadUsers();
}
}
@@ -74,7 +76,7 @@ public partial class UsersPage : ContentPage
{
await Task.Run(async () =>
{
await _userService.SyncUsers_Up((percentage, infostring) =>
await _syncService.SyncUsers_Up((percentage, infostring) =>
{
MainThread.BeginInvokeOnMainThread(() =>
{