예제 #1
0
        public ActionResult AddProductToSaleInvoice(Models.Saledto saleproduct)
        {
            var       product   = productprovider.GetById(saleproduct.ProductId);
            SoldItems soldItems = new SoldItems
            {
                ProductId = product.Id,
                UnitPrice = saleproduct.UnitPrice,
                Quantity  = saleproduct.Quantity
            };

            List <SoldItems> soldproductlist = new List <SoldItems>();
            var soldproducts = Session["soldproductlist"] as List <SoldItems>;

            if (soldproducts == null)
            {
                soldproductlist.Add(soldItems);
                Session["soldproductlist"] = soldproductlist;
            }
            else
            {
                soldproducts.Add(soldItems);
                Session["soldproductlist"] = soldproducts;
            }
            return(RedirectToAction("GetProductToSale"));
        }
        public void Update_ProductCorrectEntity_ReturnTrueAndNewEntityHasCorrectSetFields()
        {
            // Arrange
            ProductProvider productProvider = new ProductProvider();
            var             oldProducts     = productProvider.GetById(1);

            ProductHandler productHandler = new ProductHandler();
            Product        product        = new Product();

            product.Id          = 1;
            product.Name        = "NEW_Name";
            product.Description = "NEW_Description";
            product.Price       = 999.99m;
            // Act
            bool result      = productHandler.Update(product);
            var  newProducts = productProvider.GetById(1);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual("NEW_Name", newProducts.Name);
            Assert.AreEqual("NEW_Description", newProducts.Description);
            Assert.AreEqual(999.99m, newProducts.Price);
        }
        public void Delete_ProductExists_ReturnTrue()
        {
            // Arrange
            ProductProvider productProvider = new ProductProvider();
            var             allProducts     = productProvider.GetAll().OrderByDescending(p => p.Id);
            Product         lastProduct     = allProducts.FirstOrDefault() ?? new Product();
            ProductHandler  productHandler  = new ProductHandler();

            // Act
            bool result         = productHandler.Delete(lastProduct.Id);
            var  deletedProduct = productProvider.GetById(lastProduct.Id);

            // Assert
            Assert.IsTrue(result);
            Assert.IsNull(deletedProduct);
        }
예제 #4
0
 public IEnumerable <Product> GetProducts([FromBody] Guid[] ids)
 {
     return(_productProvider.GetById(ids));
 }