mirror of
https://github.com/NecroticBamboo/QRBee.git
synced 2025-12-21 12:11:53 +00:00
Files moved. Local settings saved prior to registration.
This commit is contained in:
parent
de51e8a59d
commit
1ae205298c
@ -1,4 +1,4 @@
|
|||||||
namespace QRBee.Core
|
namespace QRBee.Core.Data
|
||||||
{
|
{
|
||||||
public class ClientCardData
|
public class ClientCardData
|
||||||
{
|
{
|
||||||
@ -18,14 +18,15 @@ namespace QRBee.Droid.Services
|
|||||||
await Application.Current.SavePropertiesAsync();
|
await Application.Current.SavePropertiesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Settings> LoadSettings()
|
public Settings LoadSettings()
|
||||||
{
|
{
|
||||||
if (!Application.Current.Properties.ContainsKey("Settings"))
|
if (!Application.Current.Properties.ContainsKey("Settings"))
|
||||||
return Task.FromResult(new Settings());
|
return new Settings();
|
||||||
|
|
||||||
var json = Application.Current.Properties["Settings"].ToString();
|
var json = Application.Current.Properties["Settings"].ToString();
|
||||||
var settings = JsonConvert.DeserializeObject<Settings>(json);
|
var settings = JsonConvert.DeserializeObject<Settings>(json);
|
||||||
return Task.FromResult(settings);
|
|
||||||
|
return settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ namespace QRBee.Services
|
|||||||
{
|
{
|
||||||
string QRBeeApiUrl { get; }
|
string QRBeeApiUrl { get; }
|
||||||
Task SaveSettings(Settings settings);
|
Task SaveSettings(Settings settings);
|
||||||
Task<Settings> LoadSettings();
|
Settings LoadSettings();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,9 +44,9 @@ namespace QRBee.ViewModels
|
|||||||
IsVisible = true;
|
IsVisible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
throw;
|
await Application.Current.MainPage.DisplayAlert("Error","Wrong QR code scanned","Ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ namespace QRBee.ViewModels
|
|||||||
//Insert PIN
|
//Insert PIN
|
||||||
IsPinVisible = true;
|
IsPinVisible = true;
|
||||||
var localSettings = DependencyService.Resolve<ILocalSettings>();
|
var localSettings = DependencyService.Resolve<ILocalSettings>();
|
||||||
var pin = (await localSettings.LoadSettings()).PIN;
|
var pin = localSettings.LoadSettings().PIN;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(pin) && pin.Equals(PinCode))
|
if (!string.IsNullOrEmpty(pin) && pin.Equals(PinCode))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using QRBee.Core.Data;
|
using QRBee.Core.Data;
|
||||||
using QRBee.Services;
|
using QRBee.Services;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
@ -8,7 +9,6 @@ namespace QRBee.ViewModels
|
|||||||
internal class MerchantPageViewModel : BaseViewModel
|
internal class MerchantPageViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
private bool _isVisible;
|
private bool _isVisible;
|
||||||
private string _name;
|
|
||||||
private decimal _amount;
|
private decimal _amount;
|
||||||
private string _qrCode;
|
private string _qrCode;
|
||||||
|
|
||||||
@ -19,6 +19,8 @@ namespace QRBee.ViewModels
|
|||||||
{
|
{
|
||||||
ScanCommand = new Command(OnScanButtonClicked);
|
ScanCommand = new Command(OnScanButtonClicked);
|
||||||
GenerateQrCommand = new Command(OnGenerateQrClicked);
|
GenerateQrCommand = new Command(OnGenerateQrClicked);
|
||||||
|
var localSettings = DependencyService.Resolve<ILocalSettings>();
|
||||||
|
Name = localSettings.LoadSettings().Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnScanButtonClicked(object sender)
|
private async void OnScanButtonClicked(object sender)
|
||||||
@ -38,17 +40,7 @@ namespace QRBee.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name { get; }
|
||||||
{
|
|
||||||
get => _name;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_name == value)
|
|
||||||
return;
|
|
||||||
_name = value;
|
|
||||||
OnPropertyChanged(nameof(Name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public decimal Amount
|
public decimal Amount
|
||||||
{
|
{
|
||||||
@ -98,16 +90,24 @@ namespace QRBee.ViewModels
|
|||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
public async void OnGenerateQrClicked(object obj)
|
public async void OnGenerateQrClicked(object obj)
|
||||||
{
|
{
|
||||||
var trans = new MerchantToClientRequest
|
if (string.IsNullOrWhiteSpace(Name) || Amount==0)
|
||||||
{
|
{
|
||||||
TransactionId = Guid.NewGuid().ToString("D"),
|
await Application.Current.MainPage.DisplayAlert("Error", "The fields must be filled", "Ok");
|
||||||
Name = Name,
|
}
|
||||||
Amount = Amount,
|
else
|
||||||
TimeStampUTC = DateTime.UtcNow
|
{
|
||||||
};
|
var trans = new MerchantToClientRequest
|
||||||
// TODO Create merchant signature.
|
{
|
||||||
QrCode = trans.AsString();
|
TransactionId = Guid.NewGuid().ToString("D"),
|
||||||
IsVisible = true;
|
Name = Name,
|
||||||
|
Amount = Amount,
|
||||||
|
TimeStampUTC = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
// TODO Create merchant signature.
|
||||||
|
QrCode = trans.AsString();
|
||||||
|
IsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using QRBee.Core;
|
using QRBee.Core;
|
||||||
|
using QRBee.Core.Data;
|
||||||
using QRBee.Services;
|
using QRBee.Services;
|
||||||
using QRBee.Views;
|
using QRBee.Views;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
@ -75,16 +76,9 @@ namespace QRBee.ViewModels
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await service.RegisterAsync(new RegistrationRequest
|
|
||||||
{
|
|
||||||
DateOfBirth = DateOfBirth,
|
|
||||||
Email = Email,
|
|
||||||
Name = Name,
|
|
||||||
RegisterAsMerchant = false
|
|
||||||
});
|
|
||||||
|
|
||||||
//save local settings
|
//save local settings
|
||||||
var settings = new Settings
|
var settings = new Settings
|
||||||
{
|
{
|
||||||
CardHolderName = CardHolderName,
|
CardHolderName = CardHolderName,
|
||||||
CardNumber = CardNumber,
|
CardNumber = CardNumber,
|
||||||
@ -100,6 +94,14 @@ namespace QRBee.ViewModels
|
|||||||
};
|
};
|
||||||
await localSettings.SaveSettings(settings);
|
await localSettings.SaveSettings(settings);
|
||||||
|
|
||||||
|
await service.RegisterAsync(new RegistrationRequest
|
||||||
|
{
|
||||||
|
DateOfBirth = DateOfBirth,
|
||||||
|
Email = Email,
|
||||||
|
Name = Name,
|
||||||
|
RegisterAsMerchant = false
|
||||||
|
});
|
||||||
|
|
||||||
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
|
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@ -12,8 +12,7 @@
|
|||||||
<StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand">
|
<StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand">
|
||||||
|
|
||||||
<StackLayout Orientation="Vertical">
|
<StackLayout Orientation="Vertical">
|
||||||
<Label Text="Enter your name: " Padding="5,10,0,0"/>
|
<Label Text="{Binding Name, Mode=OneTime}" Padding="5,10,0,0"/>
|
||||||
<Entry Placeholder="Your name" HorizontalOptions="FillAndExpand" Text="{Binding Name}"/>
|
|
||||||
|
|
||||||
<Label Text="Enter sum: " Padding="5,0,0,0" />
|
<Label Text="Enter sum: " Padding="5,0,0,0" />
|
||||||
<Entry Placeholder="Amount" Keyboard="Numeric" HorizontalOptions="FillAndExpand" MaxLength="6" Text="{Binding Amount}"/>
|
<Entry Placeholder="Amount" Keyboard="Numeric" HorizontalOptions="FillAndExpand" MaxLength="6" Text="{Binding Amount}"/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user