public void Add_CalledCreateMethod()
        {
            //Arrange
            _productRepository.Setup(x => x.Create(It.IsAny <Product>()));

            //Act
            _service.AddProduct(new MProduct());

            //Assert
            _productRepository.Verify(x => x.Create(It.IsAny <Product>()), Times.Once);
        }
Exemplo n.º 2
0
        //POST: SAVING NEW PRODUCT
        public ActionResult Save(ProductModel product)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("ProductForm"));
            }
            UserLoginModel user = (UserLoginModel)HttpContext.Session["USER"];

            product.VendorId = user.Id;
            bool status = productActionContext.AddProduct(product);

            //IF UPLOAD UNSUCCESSFULL
            if (!status)
            {
                TempData["ProductNotAdded"] = true;
                return(View("ProductForm", "Product"));
            }
            //PRODUCT ADDED SUCCESSFULLY
            TempData["ProductNotAdded"] = false;
            return(RedirectToAction("VendorIndex", "User"));
        }
Exemplo n.º 3
0
        public void Post([FromBody] MProduct mProduct)
        {
            ProductActions p1 = new ProductActions();

            p1.AddProduct(mProduct);
        }
Exemplo n.º 4
0
 public async Task <int> AddProducts([FromBody] Product product)
 {
     return(await ProductActions.AddProduct(_context, product));
 }