コード例 #1
0
        public ActionResult DeleteOrder(int orderId)
        {
            var order         = _orderRepository.GetById(orderId);
            var orderProducts = _orderProductRepository.GetMany(o => o.Order.Id == orderId);

            foreach (var itemOP in orderProducts)
            {
                _orderProductRepository.Delete(itemOP);
            }
            _orderRepository.Delete(order);
            if (order != null)
            {
                TempData["Message"] = string.Format("{0} was deleted", order.Id);
            }
            _unitOfWork.Commit();
            return(RedirectToAction("Index"));
        }