Overall Bug Fixes
This commit is contained in:
parent
d6d7912c96
commit
2ed8e331ec
@ -10,5 +10,6 @@ namespace RMWPFInterfaceLibrary.Models
|
||||
string Id { get; set; }
|
||||
string LastName { get; set; }
|
||||
string Token { get; set; }
|
||||
void LogOffUser();
|
||||
}
|
||||
}
|
@ -14,5 +14,15 @@ namespace RMWPFInterfaceLibrary.Models
|
||||
public string LastName { get; set; }
|
||||
public string EmailAddress { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
|
||||
public void LogOffUser()
|
||||
{
|
||||
Token = "";
|
||||
Id = "";
|
||||
FirstName = "";
|
||||
LastName = "";
|
||||
EmailAddress = "";
|
||||
CreatedDate = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,20 @@ namespace RMWPFUserInterface.ViewModels
|
||||
var products = _mapper.Map<List<ProductDisplayModel>>(products_lsit);
|
||||
Products = new BindingList<ProductDisplayModel>(products);
|
||||
}
|
||||
private async Task ResetSalesViewModel()
|
||||
{
|
||||
Cart = new BindingList<CartItemDisplayModel>();
|
||||
// TODO - Add clearing selectedCartItem if that does not clear it
|
||||
|
||||
await LoadProducts();
|
||||
|
||||
NotifyOfPropertyChange(() => SubTotal);
|
||||
NotifyOfPropertyChange(() => Tax);
|
||||
NotifyOfPropertyChange(() => Total);
|
||||
NotifyOfPropertyChange(() => CanCheckOut);
|
||||
NotifyOfPropertyChange(() => CanAddToCart);
|
||||
|
||||
}
|
||||
private BindingList<ProductDisplayModel> _products;
|
||||
|
||||
public BindingList<ProductDisplayModel> Products
|
||||
@ -200,7 +213,7 @@ namespace RMWPFUserInterface.ViewModels
|
||||
bool output = false;
|
||||
|
||||
// Make sure something is selected
|
||||
if (SelectedCartItem != null && SelectedCartItem?.Product.QuantityInStock > 0)
|
||||
if (SelectedCartItem != null && SelectedCartItem?.QuantityInCart > 0)
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
@ -225,6 +238,7 @@ namespace RMWPFUserInterface.ViewModels
|
||||
NotifyOfPropertyChange(() => Tax);
|
||||
NotifyOfPropertyChange(() => Total);
|
||||
NotifyOfPropertyChange(() => CanCheckOut);
|
||||
NotifyOfPropertyChange(() => CanAddToCart);
|
||||
}
|
||||
|
||||
public bool CanCheckOut
|
||||
@ -256,6 +270,8 @@ namespace RMWPFUserInterface.ViewModels
|
||||
}
|
||||
|
||||
await _saleEndPoint.PostSale(sale);
|
||||
|
||||
await ResetSalesViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Caliburn.Micro;
|
||||
using RMWPFInterfaceLibrary.Models;
|
||||
using RMWPFUserInterface.EventModels;
|
||||
|
||||
namespace RMWPFUserInterface.ViewModels
|
||||
@ -13,21 +14,50 @@ namespace RMWPFUserInterface.ViewModels
|
||||
{
|
||||
private IEventAggregator _events;
|
||||
private SalesViewModel _salesVM;
|
||||
private ILoggedInUserModel _user;
|
||||
public ShellViewModel(IEventAggregator events, SalesViewModel salesVM,
|
||||
SimpleContainer container)
|
||||
SimpleContainer container, ILoggedInUserModel user)
|
||||
{
|
||||
_salesVM = salesVM;
|
||||
_events = events;
|
||||
_user = user;
|
||||
|
||||
_events.SubscribeOnUIThread(this);
|
||||
|
||||
ActivateItemAsync(IoC.Get<LoginViewModel>());
|
||||
}
|
||||
public bool IsLoggedIn
|
||||
{
|
||||
get
|
||||
{
|
||||
bool output = false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_user.Token) == false)
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
public void ExitApplication()
|
||||
{
|
||||
TryCloseAsync();
|
||||
}
|
||||
|
||||
public void LogOut()
|
||||
{
|
||||
_user.LogOffUser();
|
||||
|
||||
NotifyOfPropertyChange(() => IsLoggedIn);
|
||||
ActivateItemAsync(IoC.Get<LoginViewModel>());
|
||||
|
||||
}
|
||||
public Task HandleAsync(LogOnEvent message, CancellationToken cancellationToken)
|
||||
{
|
||||
ActivateItemAsync(_salesVM);
|
||||
|
||||
NotifyOfPropertyChange(() => IsLoggedIn);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
<DockPanel>
|
||||
<Menu DockPanel.Dock="Top" FontSize="18">
|
||||
<MenuItem Header="_File">
|
||||
|
||||
<MenuItem x:Name="ExitApplication" Header="E_xit"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Account">
|
||||
<MenuItem x:Name="LoginScreen" Header="_Login" />
|
||||
<MenuItem Header="_Account" Visibility="{Binding IsLoggedIn, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}">
|
||||
<MenuItem x:Name="LogOut" Header="_Log Out"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Grid>
|
||||
|
Loading…
Reference in New Issue
Block a user