using System.Collections.Generic;
public string Name {get;set;}
public string Description {get;set;}
public decimal Price {get;set;}
public bool IsSold {get;set;}
public bool IsPaymentDone {get;set;}
public Vendor Vendor {get;set;}
public int Stock {get;set;}
public override string ToString()
return Name + " " + Price + "$";
public string FirstName {get;set;}
public string LastName {get;set;}
public decimal Commission {get;set;}
public decimal PaymentDue {get;set;}
public override string ToString()
return FirstName + " " + LastName;
public string Name{get;set;}
public string City{get;set;}
public string ZipCode{get;set;}
public string Country{get;set;}
public string Address1{get;set;}
public string Address2{get;set;}
public List<Item> Items { get; private set; }
public List<Vendor> Vendors { get; private set; }
Items = new List<Item>();
Vendors = new List<Vendor>();
public void AddItem(Item item)
public void AddVendor(Vendor vendor)
public class ConsignmentShop
private List<KeyValuePair<Item, int>> ItemsInShoppingCart { get; set; }
private Store _Store { get; set; }
ItemsInShoppingCart = new List<KeyValuePair<Item, int>>();
private void SetupStore()
this._Store = new Store{Name = "Cool Store"};
this._Store.AddVendor(new Vendor{FirstName = "Vladimir", LastName = "Gerasimenok", Commission = 0.2m, PaymentDue = 0});
this._Store.AddVendor(new Vendor{FirstName = "Raja", LastName = "Mani", Commission = 0.3m, PaymentDue = 0});
this._Store.AddItem(new Item{Name = "C# in a Nutshell", Description = "A book from O'Reiley", Price = 50.0m, IsSold = false, IsPaymentDone = false, Vendor = this._Store.Vendors[0], Stock = 10});
this._Store.AddItem(new Item{Name = "Apple AirPods", Description = "Headphones from Apple", Price = 250.0m, IsSold = false, IsPaymentDone = false, Vendor = this._Store.Vendors[1], Stock = 5});
this._Store.AddItem(new Item{Name = "Samsung Galyx S20+", Description = "Samsung phone", Price = 1200.0m, IsSold = false, IsPaymentDone = false, Vendor = this._Store.Vendors[0], Stock = 3});
this._Store.AddItem(new Item{Name = "iMac 2011", Description = "A computer from Apple", Price = 575.0m, IsSold = false, IsPaymentDone = false, Vendor = this._Store.Vendors[1], Stock = 2});
this._Store.AddItem(new Item{Name = "AOC AG352UCG", Description = "AOC Ultrawide monitor", Price = 790.0m, IsSold = false, IsPaymentDone = false, Vendor = this._Store.Vendors[0], Stock = 5});
Console.WriteLine("Welcome to " + _Store.Name);
Console.WriteLine("Items in store: ");
for(int i = 0; i < _Store.Items.Count; i++)
Console.WriteLine((i + 1) + ", " + _Store.Items[i]);
Console.WriteLine("A - Add item to shoppping cart");
Console.WriteLine("L - List items in shoppping cart");
Console.WriteLine("O - Order items in shopping cart");
Console.WriteLine("X - Exit");
Console.WriteLine("Enter your choice:");
input = Console.ReadLine();
switch(Convert.ToChar(input))
Console.WriteLine("Place your order please");
string item = Console.ReadLine();
Item chosen = _Store.Items[Convert.ToInt32(item.Split(',')[0]) - 1];
int amount = Convert.ToInt32(item.Split(',')[1]);
if(chosen.Stock >= amount)
ItemsInShoppingCart.Add(new KeyValuePair<Item, int> (chosen, amount));
Console.WriteLine("There was not enough stock of the given item");
for(int i = 0; i < ItemsInShoppingCart.Count; i++)
Console.WriteLine(ItemsInShoppingCart[i].Key.Name + " " + ItemsInShoppingCart[i].Value + " " + ItemsInShoppingCart[i].Key.Price * ItemsInShoppingCart[i].Value);
decimal[] vendorCommission = new decimal[_Store.Vendors.Count];
for(int i = 0; i < ItemsInShoppingCart.Count; i++)
allIncome += ItemsInShoppingCart[i].Key.Price * ItemsInShoppingCart[i].Value;
vendorCommission[_Store.Vendors.IndexOf(ItemsInShoppingCart[i].Key.Vendor)] += ItemsInShoppingCart[i].Key.Price * Convert.ToDecimal(ItemsInShoppingCart[i].Value) * ItemsInShoppingCart[i].Key.Vendor.Commission;
for(int i = 0; i < vendorCommission.Length; i++)
Console.WriteLine(_Store.Vendors[i] + " " + vendorCommission[i]);
allIncome -= vendorCommission[i];
Console.WriteLine("Store income: " + allIncome);
public static void Main()
Console.WriteLine("Hello World");
ConsignmentShop mainShop = new ConsignmentShop();