예제 #1
0
        public async Task <IActionResult> Delete(int productId)
        {
            try
            {
                var product = await _repo.GetProductAsyncByIdAsync(productId, false);

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

                _repo.Delete(product);

                if (await _repo.SaveChangesAsync())
                {
                    return(Ok());
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco Dados Falhou"));
            }

            return(BadRequest());
        }
예제 #2
0
        public ActionResult confirmDelProd(int id)
        {
            var product = _ProductRepository.Get(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            _ProductRepository.Delete(product);
            return(null);
        }
예제 #3
0
        public async Task <ServiceResponse> Delete(int idProduct)
        {
            var sr = new ServiceResponse();

            try
            {
                sr.Data = await _repositoryProduct.Delete(idProduct);
            }
            catch (Exception ex)
            {
                sr.AddError(ex);
            }

            return(sr);
        }
예제 #4
0
        public async Task <IActionResult> DeleteProduct(int productCode)
        {
            try
            {
                var productCod = await _efCoreRepositoryProduct.Delete(productCode);

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

                return(Ok(productCod));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
예제 #5
0
        public IActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest("Parâmetro nullo"));
            }

            try
            {
                _repository.Delete(id);
                _repository.Save();
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(Ok("Produto delatado com sucesso"));
        }