public ActionResult Index([Bind(Include = "ProductKey, ProductName, Price, Quantity")] BakeryItem i) { // Receipt: Dark Chocolate Bar ($4.50) qty 2. Subtotal: $9.00. Tax: $0.90. Total: $9.90 Message m = new Message(); var prod = from p in db.Products where p.ProductKey == i.ProductKey select new { p.ProductName, p.ProductPrice }; foreach (var pr in prod) { i.ProductName = pr.ProductName.ToString(); i.Price = (decimal)pr.ProductPrice; } decimal subtotal = i.Price * i.Quantity; decimal taxrate = 0.1m; decimal tax = subtotal * taxrate; decimal total = subtotal + tax; m.MessageText = "Receipt: " + i.ProductName + " ($" + i.Price + ") qty " + i.Quantity + ". Subtotal: $" + subtotal + ". Tax: $" + tax + ". Total: $" + total; return(View("Result", m)); }
public void ConstructorTest_True() { BakeryItem item = new BakeryItem("Eclair", 2, 1); Assert.AreEqual(typeof(BakeryItem), item.GetType()); Assert.AreEqual("Eclair", item.ItemName); }