Exemple #1
0
        public async Task <IActionResult> DeleteAsync(int id, CancellationToken cancellationToken)
        {
            InitUserInfo();
            if (!AllowDelete)
            {
                return(ValidationProblem());
            }
            // validate if data exists
            var itemToDelete = await _purchaseOrderDetailService.GetByIdAsync(id, cancellationToken);

            if (itemToDelete == null)
            {
                throw new EntityNotFoundException(nameof(PurchaseOrderDetail), id);
            }

            // delete data
            var result = await _purchaseOrderDetailService.DeleteAsync(itemToDelete, cancellationToken);

            if (!result)
            {
                AssignToModelState(_purchaseOrderDetailService.Errors);
                return(ValidationProblem());
            }

            return(NoContent());
        }