Exemplo n.º 1
0
        public ActionResult PartyHireInformation(Order order)
        {
            if(order.ContainsHireProducts() || order.ContainsTheme())
            {
                Party party = this._queryDispatcher.Dispatch<Party, GetPartyByOrderGuidQuery>(new GetPartyByOrderGuidQuery(order.Guid));
                if (party != null)
                {
                    PartyViewModel viewModel = new PartyViewModel(party);

                    if(party.DropoffAddress.HasValue)
                    {
                        var address = this._queryDispatcher.Dispatch<Address, GetAddressByGuidQuery>(new GetAddressByGuidQuery(party.DropoffAddress.Value));
                        viewModel.DropoffAddress = new DeliveryAddressViewModel(address);
                    }

                    if(party.PickupAddress.HasValue)
                    {
                        var address = this._queryDispatcher.Dispatch<Address, GetAddressByGuidQuery>(new GetAddressByGuidQuery(party.PickupAddress.Value));
                        viewModel.PickupAddress = new DeliveryAddressViewModel(address);
                    }

                    return this.PartialView("PartyHireInformation", viewModel);
                }
            }

            return null;
        }
        public BillingAddressViewModel(Member member, Order order, Address address)
            : base(address)
        {
            if (address != null && !string.IsNullOrEmpty(address.Email))
            {
                this.Email = address.Email;
            }
            else
            {
                this.Email = member.Email;
            }

            this.OrderContainsBuyItems = order.ContainsBuyProducts() && !order.ContainsHireProducts() && !order.ContainsTheme();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public ActionResult PartyHireInformation(Order order, Member member)
        {
            if (order.ContainsHireProducts() || order.ContainsTheme())
            {
                Party party = this._queryDispatcher.Dispatch<Party, GetPartyByOrderGuidQuery>(new GetPartyByOrderGuidQuery(order.Guid));

                PartyHireInformationViewModel viewModel = new PartyHireInformationViewModel(null, order, party);

                if (order.DeliveryAddressId.HasValue)
                {
                    Address address = this._queryDispatcher.Dispatch<Address, GetAddressByGuidQuery>(new GetAddressByGuidQuery(order.DeliveryAddressId.Value));
                    viewModel = new PartyHireInformationViewModel(address, order, party);
                }
                else if (member.DeliveryAddresses.Any())
                {
                    Address address = member.DeliveryAddresses.OrderByDescending(o => o.DateCreated).First();
                    viewModel = new PartyHireInformationViewModel(address, order, party);
                }

                return this.View("PartyHireInformation", viewModel);
            }

            return this.RedirectToRoute(Routes.Checkout.BillingInformation);
        }