public ActionResult BillingInformation(Order order, Member member) { var viewModel = new BillingAddressViewModel(member, order); if (order.BillingAddressId.HasValue) { Address address = this._queryDispatcher.Dispatch<Address, GetAddressByGuidQuery>(new GetAddressByGuidQuery(order.BillingAddressId.Value)); viewModel = new BillingAddressViewModel(member, order, address); } else if (member.BillingAddresses.Any()) { Address address = member.BillingAddresses.OrderByDescending(o => o.DateCreated).First(); viewModel = new BillingAddressViewModel(member, order, address); } return this.View("BillingInformation", viewModel); }
public ActionResult BillingInformation(BillingAddressViewModel viewModel, Order order, Member member, bool? shippingAddressIsTheSame) { if (this.ModelState.IsValid) { Address billingAddress = this._addressProvider.SaveBillingAddress(member, viewModel, viewModel.Email); this._commandDispatcher.Dispatch<AddBillingAddressCommand>(new AddBillingAddressCommand(order, billingAddress)); if ((shippingAddressIsTheSame.HasValue && shippingAddressIsTheSame.Value)) { viewModel.Guid = Guid.NewGuid(); Address shippingAddress = this._addressProvider.SaveShippingAddress(member, viewModel); this._commandDispatcher.Dispatch<AddShippingAddressCommand>(new AddShippingAddressCommand(order, shippingAddress)); return this.RedirectToRoute(Routes.Checkout.PaymentInfo); } else { if (order.ContainsBuyProducts() && !order.ContainsHireProducts() && !order.ContainsTheme()) { return this.RedirectToRoute(Routes.Checkout.ShippingInformation, new { guid = string.Empty }); } return this.RedirectToRoute(Routes.Checkout.PaymentInfo); } } return this.View("BillingInformation", viewModel); }