@ -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 | |||||
} | |||||
} |
@ -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> |
@ -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 | |||||
} |