Browse Source

Voucher Scan history page Implemented and its View models

master
Kaustav Chaudhuri 1 year ago
parent
commit
6b798afb32
3 changed files with 105 additions and 0 deletions
  1. +56
    -0
      GMCabsDriverAssistantSolution/ViewModels/VoucherScanHistoryViewModel.cs
  2. +22
    -0
      GMCabsDriverAssistantSolution/Views/VoucherScanHistory.xaml
  3. +27
    -0
      GMCabsDriverAssistantSolution/Views/VoucherScanHistory.xaml.cs

+ 56
- 0
GMCabsDriverAssistantSolution/ViewModels/VoucherScanHistoryViewModel.cs View File

@ -0,0 +1,56 @@
using GMCabsDriverAssistant.Services;
using GMCabsDriverAssistant.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GMCabsDriverAssistantSolution.ViewModels
{
public class VoucherScanHistoryViewModel : BaseViewModel
{
#region Fields
private int voucherScanCount = 0;
#endregion
#region Properties
public int VoucherScanCount
{
get => voucherScanCount;
set => SetProperty(ref voucherScanCount, value);
}
#endregion
#region Constructor
public VoucherScanHistoryViewModel()
{
Title = "Voucher Scan History";
DateTime reportingDate = DateTime.Now;
VoucherScanedCount(reportingDate);
}
#endregion
#region Methods
public void OnDateSelected(object sender, DateChangedEventArgs args)
{
DateTime reportingDate = args.NewDate;
VoucherScanedCount(reportingDate);
}
private async void VoucherScanedCount(DateTime reportingDate)
{
int count;
var token = Preferences.Get(SecureStorageData.Token, "");
if (token != null)
{
GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
count = await gmCabsDriverService.VoucherScanedCount(token, reportingDate);
VoucherScanCount = count;
}
}
#endregion
}
}

+ 22
- 0
GMCabsDriverAssistantSolution/Views/VoucherScanHistory.xaml View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="GMCabsDriverAssistantSolution.Views.VoucherScanHistory"
xmlns:vm="clr-namespace:GMCabsDriverAssistantSolution.ViewModels"
Shell.FlyoutBehavior="Disabled"
Title="{Binding Title}">
<ContentPage.BindingContext>
<vm:VoucherScanHistoryViewModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<DatePicker x:Name="reportDatePicker"
DateSelected="OnDateSelected" BackgroundColor="White"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="Vouchers Redeemed:" TextColor="Black" FontSize="22"/>
<Label Text="{Binding VoucherScanCount}" TextColor="Black" FontSize="22"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

+ 27
- 0
GMCabsDriverAssistantSolution/Views/VoucherScanHistory.xaml.cs View File

@ -0,0 +1,27 @@
using GMCabsDriverAssistantSolution.ViewModels;
namespace GMCabsDriverAssistantSolution.Views;
public partial class VoucherScanHistory : ContentPage
{
#region Fields
private readonly VoucherScanHistoryViewModel _viewModel;
#endregion
#region Properties
#endregion
#region Constructor
public VoucherScanHistory()
{
InitializeComponent();
BindingContext = _viewModel = new VoucherScanHistoryViewModel();
}
#endregion
public void OnDateSelected(object sender, DateChangedEventArgs args)
{
_viewModel.OnDateSelected(sender, args);
}
#region Methods
#endregion
}

Loading…
Cancel
Save