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
|
||||
{
|
||||
@ -18,14 +18,15 @@ namespace QRBee.Droid.Services
|
||||
await Application.Current.SavePropertiesAsync();
|
||||
}
|
||||
|
||||
public Task<Settings> LoadSettings()
|
||||
public Settings LoadSettings()
|
||||
{
|
||||
if (!Application.Current.Properties.ContainsKey("Settings"))
|
||||
return Task.FromResult(new Settings());
|
||||
return new Settings();
|
||||
|
||||
var json = Application.Current.Properties["Settings"].ToString();
|
||||
var settings = JsonConvert.DeserializeObject<Settings>(json);
|
||||
return Task.FromResult(settings);
|
||||
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ namespace QRBee.Services
|
||||
{
|
||||
string QRBeeApiUrl { get; }
|
||||
Task SaveSettings(Settings settings);
|
||||
Task<Settings> LoadSettings();
|
||||
Settings LoadSettings();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -44,9 +44,9 @@ namespace QRBee.ViewModels
|
||||
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
|
||||
IsPinVisible = true;
|
||||
var localSettings = DependencyService.Resolve<ILocalSettings>();
|
||||
var pin = (await localSettings.LoadSettings()).PIN;
|
||||
var pin = localSettings.LoadSettings().PIN;
|
||||
|
||||
if (!string.IsNullOrEmpty(pin) && pin.Equals(PinCode))
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using QRBee.Core.Data;
|
||||
using QRBee.Services;
|
||||
using Xamarin.Forms;
|
||||
@ -8,7 +9,6 @@ namespace QRBee.ViewModels
|
||||
internal class MerchantPageViewModel : BaseViewModel
|
||||
{
|
||||
private bool _isVisible;
|
||||
private string _name;
|
||||
private decimal _amount;
|
||||
private string _qrCode;
|
||||
|
||||
@ -19,6 +19,8 @@ namespace QRBee.ViewModels
|
||||
{
|
||||
ScanCommand = new Command(OnScanButtonClicked);
|
||||
GenerateQrCommand = new Command(OnGenerateQrClicked);
|
||||
var localSettings = DependencyService.Resolve<ILocalSettings>();
|
||||
Name = localSettings.LoadSettings().Name;
|
||||
}
|
||||
|
||||
private async void OnScanButtonClicked(object sender)
|
||||
@ -38,17 +40,7 @@ namespace QRBee.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
if (_name == value)
|
||||
return;
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
public string Name { get; }
|
||||
|
||||
public decimal Amount
|
||||
{
|
||||
@ -97,6 +89,12 @@ namespace QRBee.ViewModels
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public async void OnGenerateQrClicked(object obj)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name) || Amount==0)
|
||||
{
|
||||
await Application.Current.MainPage.DisplayAlert("Error", "The fields must be filled", "Ok");
|
||||
}
|
||||
else
|
||||
{
|
||||
var trans = new MerchantToClientRequest
|
||||
{
|
||||
@ -111,4 +109,6 @@ namespace QRBee.ViewModels
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using QRBee.Core;
|
||||
using QRBee.Core.Data;
|
||||
using QRBee.Services;
|
||||
using QRBee.Views;
|
||||
using Xamarin.Forms;
|
||||
@ -75,13 +76,6 @@ namespace QRBee.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
await service.RegisterAsync(new RegistrationRequest
|
||||
{
|
||||
DateOfBirth = DateOfBirth,
|
||||
Email = Email,
|
||||
Name = Name,
|
||||
RegisterAsMerchant = false
|
||||
});
|
||||
|
||||
//save local settings
|
||||
var settings = new Settings
|
||||
@ -100,6 +94,14 @@ namespace QRBee.ViewModels
|
||||
};
|
||||
await localSettings.SaveSettings(settings);
|
||||
|
||||
await service.RegisterAsync(new RegistrationRequest
|
||||
{
|
||||
DateOfBirth = DateOfBirth,
|
||||
Email = Email,
|
||||
Name = Name,
|
||||
RegisterAsMerchant = false
|
||||
});
|
||||
|
||||
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@ -12,8 +12,7 @@
|
||||
<StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand">
|
||||
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label Text="Enter your name: " Padding="5,10,0,0"/>
|
||||
<Entry Placeholder="Your name" HorizontalOptions="FillAndExpand" Text="{Binding Name}"/>
|
||||
<Label Text="{Binding Name, Mode=OneTime}" Padding="5,10,0,0"/>
|
||||
|
||||
<Label Text="Enter sum: " Padding="5,0,0,0" />
|
||||
<Entry Placeholder="Amount" Keyboard="Numeric" HorizontalOptions="FillAndExpand" MaxLength="6" Text="{Binding Amount}"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user