[HttpPost("/vendors/{vendorId}/orders")] //Creates new order within a Vendor public ActionResult Create(int vendorId, string OrderInfo, string OrderPrice, string OrderDate) { Dictionary <string, object> model = new Dictionary <string, object>(); Vend foundVend = Vend.FindVend(vendorId); Order newOrder = new Order(OrderInfo, OrderPrice, OrderDate); foundVend.AddOrder(newOrder); List <Order> allVendOrders = foundVend.Orders; model.Add("orders", allVendOrders); model.Add("vendor", foundVend); return(View("Show", model)); }
public void AddOrder_AssignsAnOrderToAVendor_OrderList() { string info = "12 Cupcakes, 12 Cake Pops"; string price = "$20"; string date = "08/15/1996"; Order newOrder = new Order(info, price, date); List <Order> newOrderList = new List <Order> { newOrder }; string VendName = "Suzie's Cupcakes"; Vend newVend = new Vend(VendName); newVend.AddOrder(newOrder); List <Order> result = newVend.Orders; CollectionAssert.AreEqual(newOrderList, result); }