Skip to content

Instantly share code, notes, and snippets.

@mortezadalil
Created February 2, 2022 15:07
Show Gist options
  • Save mortezadalil/ed7cbe0952aff45fba26711afa2d75f8 to your computer and use it in GitHub Desktop.
Save mortezadalil/ed7cbe0952aff45fba26711afa2d75f8 to your computer and use it in GitHub Desktop.
namespace Basket.Api.Models
{
public class Basket
{
public Basket(string userName)
{
this.UserName = userName;
}
public string UserName { get; set; }
public List<BasketItem> BasketItems
{
get; set;
} = new List<BasketItem>();
public long TotalPrice
{
get
{
return BasketItems.Sum(x => x.Price * x.Count);
}
}
}
public class BasketItem
{
public int Count { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public long Price { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment