Example #1
0
        public ActionResult Delete(int id, int?categoryid)
        {
            _productsBL.Delete(id);

            ProductsFilterViewModel filterViewModel = new ProductsFilterViewModel();

            filterViewModel.Category.Id = categoryid;
            TempData[Constants.TempDataKeys.PRODUCTS_FILTER_VIEW_MODEL] = filterViewModel;
            return(RedirectToAction("Index"));
        }
Example #2
0
        public void Delete_ShouldUnassignFromCtegories()
        {
            //Arrange
            ResetDataBase();
            ProductsBL productsBL = DI.Resolve <ProductsBL>();

            //Act
            productsBL.Delete(1);

            //Assert
            bool isDeleted = EntityFrameworkDbContext.Products.Where(product => product.Id == 1).Select(product => product.IsDeleted).Single();

            Assert.That(isDeleted, Is.True);
        }
        public IActionResult DeleteProduct([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var product = productsBL.findById(id);

            if (product == null)
            {
                return(NotFound());
            }

            productsBL.Delete(product);

            return(Ok(product));
        }