示例#1
0
        public CreateOrderResponse CreateOrder(CreateOrderRequest request)
        {
            CreateOrderResponse response = new CreateOrderResponse();
            Customer customer = _customerRepository.FindBy(request.CustomerIdentityToken);
            Basket basket = _basketRepository.FindBy(request.BasketId);
            DeliveryAddress deliveryAddress = customer.DeliveryAddressBook.Where(d => d.Id == request.DeliveryId).FirstOrDefault();

            Order order = basket.ConvertToOrder();
            order.Customer = customer;
            order.DeliveryAddress = deliveryAddress;
            _orderRepository.Save(order);
            _basketRepository.Remove(basket);
            _uow.Commit();
            response.Order = order.ConvertToOrderView();
            return response;
        }
        public ActionResult PlaceOrder(FormCollection collection)
        {
            CreateOrderRequest request = new CreateOrderRequest();
            request.BasketId = base.GetBasketId();
            request.CustomerIdentityToken = _formsAuthentication.GetAuthenticationToken();
            request.DeliveryId = int.Parse(collection[FormDataKeys.DeliveryAddress.ToString()]);

            CreateOrderResponse response = _orderService.CreateOrder(request);
            _cookieStorageService.Save(CookieDataKeys.BasketItems.ToString(), "0", DateTime.Now.AddDays(1));
            _cookieStorageService.Save(CookieDataKeys.BasketTotal.ToString(), "0", DateTime.Now.AddDays(1));
            return RedirectToAction("CreatePaymentFor", "Payment", new { orderId = response.Order.Id });
        }