public void AddProductAddInvoiceLineToInvoice()
        {
            //Arange
            var expected = new InvoiceLine{ProductId = "3"};

            var sut = new InvoiceLineController{Cache = CacheMock.Object};

            //Act
            sut.AddProduct(expected);

            //Assert
            Assert.IsTrue(sut.Invoice.Lines.Contains(expected));
            Assert.IsNotNull(expected.Product);
            Assert.AreEqual("3", expected.Product.Number);
        }
Esempio n. 2
0
        public ActionResult AddProduct(InvoiceLine model)
        {
            if (ModelState.IsValid)
            {
                object customerId = null;

                if (Invoice != null)
                {
                    model.Product = Products.Single(product => product.Number == model.ProductId);
                    Invoice.AddLine(model);
                    customerId = new {CustomerId = Invoice.CustomerId};
                }

                return RedirectToAction("Create", "Invoice", customerId );
            }
            ViewData["Products"] = GetProductSelectListItems();
            return View(model);
        }
Esempio n. 3
0
 public void RemoveLine(InvoiceLine invoiceLine)
 {
     _invoiceLines.Remove(invoiceLine);
 }
Esempio n. 4
0
 public void AddLine(InvoiceLine invoiceLine)
 {
     _invoiceLines.Add(invoiceLine);
 }