Пример #1
0
        public ActionResult <Orderline> Delete(int id)
        {
            Orderline line = _orderlineRepository.getById(id);

            _orderlineRepository.Delete(line);
            _orderlineRepository.SaveChanges();
            return(line);
        }
Пример #2
0
        public async Task <Orderline> DeleteOrderline(int orderId, int orderlineId)
        {
            var order = await _orderRepository.FindByIdAsync(orderId);

            if (order == null)
            {
                throw new EntityNotFoundException($"Order met id {orderId} werd niet gevonden.");
            }

            var orderlineToDelete = order.Orderlines.FirstOrDefault(x => x.Id == orderlineId);

            _orderlineRepository.Delete(orderlineToDelete);

            await _orderlineRepository.SaveChangesAsync();

            return(orderlineToDelete);
        }