public async Task <IActionResult> Delete(int id)
 {
     if (id <= 0)
     {
         return(BadRequest("Please specify correct Product Id"));
     }
     return(Ok(await _productsService.DeleteProductAsync(id)));
 }
        public async Task <ActionResult> Delete(int id)
        {
            if (await _productsService.GetProductAsync(id) == null)
            {
                return(NotFound());
            }

            await _productsService.DeleteProductAsync(id);

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> DeleteProduct(int id)
        {
            var products = await _productsService.GetProductsAsync();

            if (!products.Any(product => product.Id == id))
            {
                return(BadRequest("Product id not found"));
            }

            await _productsService.DeleteProductAsync(id);

            return(Ok(id));
        }
示例#4
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                await _productsService.DeleteProductAsync(id);
            }
            catch (EntityNotFoundException)
            {
                return(NotFound($"Product with id {id} was not found"));
            }

            return(NoContent());
        }
示例#5
0
 public Task Delete(int productId)
 {
     return(_productsService.DeleteProductAsync(productId, HttpContext.RequestAborted));
 }
示例#6
0
 public async Task <IActionResult> DeleteProductAsync(int id)
 {
     return(await _productsService.DeleteProductAsync(id));
 }
        public async Task <IActionResult> DeleteProduct(int id)
        {
            var response = await _productsService.DeleteProductAsync(id);

            return(Ok(response));
        }
示例#8
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _productsService.DeleteProductAsync(id);

            return(RedirectToAction(nameof(Index)));
        }
示例#9
0
        public async Task <IActionResult> DeleteProductAsync(int id)
        {
            ProductViewModel productViewModel = await _productsService.DeleteProductAsync(id);

            return(new OkObjectResult(productViewModel));
        }
示例#10
0
        public async Task <IActionResult> DeleteProductById(int id)
        {
            await _productsService.DeleteProductAsync(id);

            return(NoContent());
        }