Ejemplo n.º 1
0
 public IActionResult DeleteProduct(int id)
 {
     if (id <= 0)
     {
         return(NotFound());
     }
     _productRepo.DeleteProduct(id);
     _productRepo.CommitChanges();
     return(Ok());
 }
Ejemplo n.º 2
0
        public ActionResult Delete(int productId)
        {
            Product deletedP = repository.DeleteProduct(productId);

            if (deletedP != null)
            {
                TempData["message"] = $"{deletedP.Name}已经被删除!";
            }
            return(RedirectToAction("Index"));
        }
 //To Delete the record on a particular Product
 public async Task DeleteProduct(int?id)
 {
     try
     {
         await _iProductRepo.DeleteProduct(id);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Ejemplo n.º 4
0
 public ActionResult <string> Delete(int id)
 {
     if (id != 0)
     {
         if (_repository.DeleteProduct(id))
         {
             return(Ok("Deleted"));
         }
     }
     return(NotFound("Not Found"));
 }
Ejemplo n.º 5
0
 public bool RemoveProduct(int id)
 {
     if (id <= 0)
     {
         throw new Exception("Minimum ID is 1.");
     }
     else
     {
         return(_productRepo.DeleteProduct(id));
     }
 }
Ejemplo n.º 6
0
        public ActionResult DeleteProduct(int id)
        {
            var productInDb = _repository.GetProductById(id);

            if (productInDb == null)
            {
                return(NotFound());
            }
            _repository.DeleteProduct(productInDb);
            _repository.SaveChanges();
            return(NoContent());
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> DeleteProduct(string id)
        {
            if (await _repo.GetProduct(id) == null)
            {
                return(NotFound());
            }
            var response = await _repo.DeleteProduct(id);

            if (!response)
            {
                return(BadRequest("Something went wrong"));
            }
            return(Ok("Product removed successfully"));
        }
Ejemplo n.º 8
0
        public IActionResult Delete(int id)
        {
            Product product = null;

            product = _productRepo.DeleteProduct(id);

            if (product != null)
            {
                return(Ok(product));
            }
            else
            {
                return(NotFound("Product with Id = " + id.ToString() + " not found to Delete."));
            }
        }
Ejemplo n.º 9
0
 public IActionResult Delete(long id)
 {
     repo.DeleteProduct(id);
     return(RedirectToAction(nameof(Index)));
 }
 public void DeleteProduct(Product product)
 {
     repo.DeleteProduct(product);
 }
Ejemplo n.º 11
0
        public async Task <IActionResult> DeleteProduct(int productId)
        {
            var data = await _repo.DeleteProduct(productId);

            return(Ok(data));
        }
Ejemplo n.º 12
0
        public void Delete(int id)
        {
            var productToDelete = _repo.GetProduct(id);

            _repo.DeleteProduct(productToDelete);
        }
Ejemplo n.º 13
0
        public IActionResult DeleteProduct(Product product)
        {
            repo.DeleteProduct(product);

            return(RedirectToAction("Index"));
        }
 public Product RemoveProduct(int id)
 {
     return(_productRepo.DeleteProduct(id));
 }
Ejemplo n.º 15
0
 public Task <bool> Handle(DeleteProductCommand request, CancellationToken cancellationToken)
 {
     return(Task.FromResult(_repository.DeleteProduct(request.Id)));
 }