예제 #1
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            var result = await _stockRepository.DeleteAsync(id);


            return(Ok(result));
        }
예제 #2
0
        public async Task <IActionResult> Delete([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var stock = _stockRepository.DeleteAsync(id);

            return(Ok(stock.Result));
        }
예제 #3
0
        public async Task DeleteById(int id)
        {
            var item = await _repository.GetOneByIdAsync(id);

            if (item is null)
            {
                throw new NotFoundException(ExceptionMessageUtil.NOT_FOUND);
            }

            await _repository.DeleteAsync(item);
        }
        public async Task <IActionResult> DeleteAsync(int id)
        {
            try {
                await _stockRepository.DeleteAsync(id);
            } catch (InvalidOperationException e) {
                _logger.LogInformation(e, $"Found no stock entry with id: {id}.");
                return(NotFound(e.Message));
            }

            return(NoContent());
        }
예제 #5
0
        public async Task <BaseResponse> DeleteAsync(UserUIDAndUIDRequest request)
        {
            BaseResponse _Response = new BaseResponse();

            if (request.UID == Guid.Empty || !await __StockRepository.DeleteAsync(request.UID, request.UserUID))
            {
                _Response.Success      = false;
                _Response.ErrorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} delete {ENTITY_NAME}.";
            }

            return(_Response);
        }
예제 #6
0
        public async Task <IActionResult> DeleteStock([Required] int stockId)
        {
            var stock = await _stockRepository.GetAsync(stockId);

            if (stock == null)
            {
                return(NotFound($"Stock {stockId} not found"));
            }

            await _stockRepository.DeleteAsync(stockId);

            await _stockRepository.UnitOfWork.SaveEntitiesAsync();

            return(StatusCode(204));
        }
예제 #7
0
        public async Task <ActionResult <Stock> > DeleteStock(int id)
        {
            try
            {
                var stock = await _stockRepository.GetByIdAsync(id);

                if (stock != null)
                {
                    await _stockRepository.DeleteAsync(stock);

                    return(Ok("Stock deleted"));
                }
                return(BadRequest("Could not delete stock."));
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception deleting the stock: " + ex.Message);
                return(BadRequest());
            }
        }
예제 #8
0
 public async Task RemoveAsync(int id)
 {
     await ItemsInStockRepository.DeleteAsync(id);
 }