Наследование: DomainObject
Пример #1
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                _orderRepository.EnsurePersistent(order);

                _messageFactory.SendNewOrderMessage();

                Message = "New Order Created Successfully";

                return RedirectToAction("Index");
            }
            else
            {
                _orderRepository.DbContext.RollbackTransaction();

                var viewModel = OrderViewModel.Create(Repository.OfType<Customer>());
                viewModel.Order = order;

                return View(viewModel);
            }
        }
Пример #2
0
        public ActionResult Edit(Order order)
        {
            var orderToUpdate = _orderRepository.GetNullableById(order.Id);
            TransferValuesTo(orderToUpdate, order);

            orderToUpdate.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _orderRepository.EnsurePersistent(orderToUpdate);

                Message = "Order edited successfully";

                return RedirectToAction("Index");
            }
            else
            {
                var viewModel = OrderViewModel.Create(Repository.OfType<Customer>());
                viewModel.Order = order;

                return View(viewModel);
            }
        }
Пример #3
0
 private static void TransferValuesTo(Order orderToUpdate, Order order)
 {
     orderToUpdate.OrderDate = order.OrderDate;
     orderToUpdate.OrderedBy = order.OrderedBy;
     orderToUpdate.ShipAddress = order.ShipAddress;
 }