Retail_manager/RMWPFUserInterface/Models/CartItemDisplayModel.cs
s459315 4a4fc708c7 Update Cart Quantites
Add AutoMapper and INotifyPropertyChanged to enable cart quantity changes to be reflected
2022-07-27 14:57:33 +02:00

42 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RMWPFUserInterface.Models
{
public class CartItemDisplayModel : INotifyPropertyChanged
{
public ProductDisplayModel Product { get; set; }
private int _quantityInCart;
public int QuantityInCart
{
get { return _quantityInCart; }
set
{
_quantityInCart = value;
CallPropertyChanges(nameof(QuantityInCart));
CallPropertyChanges(nameof(DisplayText));
}
}
public string DisplayText
{
get
{
return $"{Product.ProductName} ({QuantityInCart})";
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void CallPropertyChanges(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}