Exemplo n.º 1
0
        public async Task <ActionResult> Delete(int id, Product product)
        {
            try
            {
                await _serviceProduct.Delete(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public void DeletarProduto()
        {
            ProductEntity product = new ProductEntity()
            {
                Name = "Arroz", Discount = 20, Price = 19, Stock = 30
            };

            Moq.Mock <IServiceProduct> mock = new Moq.Mock <IServiceProduct>();
            mock.Setup(p => p.Insert(product)).ReturnsAsync(product);
            mock.Setup(p => p.Delete(product.Id)).ReturnsAsync(true);

            IServiceProduct service = mock.Object;

            service.Insert(product);
            var result = service.Delete(product.Id);

            Assert.True(result.Result);
        }
Exemplo n.º 3
0
 public bool Delete(int id)
 {
     return(_serviceProduct.Delete(id));
 }
 public async Task Delete(ProductDto productDto)
 {
     var product = mapper.Map <Product>(productDto);
     await serviceProduct.Delete(product);
 }