using System.Collections.Generic;
public static void Main()
ConsignmentShop consignmentshop=new ConsignmentShop();
consignmentshop.ShowMenu();
public override string ToString()
return $"{Name} ${Price}";
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 $"{FirstName} ${LastName}";
public string FirstName {get;set;}
public string LastName {get;set;}
public decimal Commission {get;set;}
public decimal PaymentDue {get;set;}
Vendors=new List<Vendor>();
public void AddItem(Item item)
public void AddVendor(Vendor vendor)
public List<Vendor> Vendors{get; private set;}
public List<Item> Items{get; private set;}
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 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 = "Interview Store"};
this.store.AddVendor(new Vendor{FirstName = "Anand", LastName = "Seshadri", 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(this.store.Name);
foreach(var item in this.store.Items)
Console.WriteLine( $"{count} {item.Name}" );
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 ");
var input=Console.ReadLine();
Console.Write("Enter item number, quantity: ");
string iteminput=Console.ReadLine();
var inputdata=iteminput.Split(',');
int number=Convert.ToInt32(inputdata[0])-1;
int quantity=Convert.ToInt32(inputdata[1]);
if(this.store.Items[number].Stock >quantity)
ItemsInShoppingCart.Add(new KeyValuePair<Item,int>(this.store.Items[number],quantity));
this.store.Items[number].Stock-=quantity;
Console.WriteLine($"Sorry! The item {this.store.Items[number].Name} is out of stock. {this.store.Items[number].Stock} items remain.");
foreach(var itemincart in ItemsInShoppingCart)
Console.WriteLine($"{itemincart.Key.ToString() } X {itemincart.Value} = {itemincart.Key.Price*itemincart.Value}" ) ;
foreach(var itemincart in ItemsInShoppingCart)
var vendorprofit=itemincart.Key.Vendor.Commission*itemincart.Value*itemincart.Key.Price;
totalordervalue+=itemincart.Key.Price*itemincart.Value;
storeprofit+=(itemincart.Key.Price*itemincart.Value)-vendorprofit;
itemincart.Key.Vendor.PaymentDue+=vendorprofit;
Console.WriteLine($"Total Order Amount : ${totalordervalue}");
Console.WriteLine($"Total Store Profit : ${storeprofit}");
foreach(var vendor in this.store.Vendors)
Console.WriteLine($"{vendor.ToString()} gets ${vendor.PaymentDue}");