public OrderViewModel(Order order, Member member) { this.OrderItems = order.Items.Select(o => new OrderItemViewModel(o)).ToList(); this.Total = order.Total.ToString("C2"); this.OrderNumber = order.Id.ToString("D5"); this.Id = order.Id; this.Guid = order.Guid; this.Status = order.Status; this.DatePaid = order.DatePaid; this.DateCreated = order.DateCreated; this.Member = new MemberViewModel(member); if (order.BillingAddressId.HasValue && member.BillingAddresses.Any(o => o.Guid == order.BillingAddressId.Value)) { var address = member.BillingAddresses.First(o => o.Guid == order.BillingAddressId.Value); this.BillingAddress = new BillingAddressViewModel(address); } if (order.ShippingAddressId.HasValue && member.ShippingAddresses.Any(o => o.Guid == order.ShippingAddressId.Value)) { var address = member.ShippingAddresses.First(o => o.Guid == order.ShippingAddressId.Value); this.ShippingAddress = new AddressViewModel(address); } if (order.DeliveryAddressId.HasValue && member.DeliveryAddresses.Any(o => o.Guid == order.DeliveryAddressId.Value)) { var address = member.DeliveryAddresses.First(o => o.Guid == order.DeliveryAddressId.Value); this.DeliveryAddress = new DeliveryAddressViewModel(address); } this.IsPickup = order.Items.Any(o => o.Product.Type == Common.Enums.ProductType.Delivery && o.Product.Title == "Pickup Hire Delivery"); this.IsDropoff = order.Items.Any(o => o.Product.Type == Common.Enums.ProductType.Delivery && o.Product.Title == "Dropoff Hire Delivery"); }
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 ActionResult ApplyDiscount(Order order, string number) { LoyaltyCard loyaltyCard = this._queryDispatcher.Dispatch<LoyaltyCard, GetLoyaltyCardQuery>(new GetLoyaltyCardQuery(number)); if (loyaltyCard != null) { if (loyaltyCard.Status == Orders.Enums.LoyaltyCardStatus.Available) { this._commandDispatcher.Dispatch<ApplyDiscountCommand>(new ApplyDiscountCommand(order, loyaltyCard)); return this.Json(new { Status = "Applied" }); } if (loyaltyCard.Status == Orders.Enums.LoyaltyCardStatus.Expired) { return this.Json(new { Status = "Expired" }); } if (loyaltyCard.Status == Orders.Enums.LoyaltyCardStatus.Used) { return this.Json(new { Status = "Used" }); } } return this.Json(new { Status = "Not Found" }); }
public ActionResult AddHireProduct(int productId, Member member, Order order, DateTime partyDate, int qty = 1) { Product product = this._queryDispatcher.Dispatch<Product, GetProductByIdQuery>(new GetProductByIdQuery(productId)); this._commandDispatcher.Dispatch(new AddHireProductToCartCommand(member.Guid, qty, product, partyDate)); Cart cart = this._queryDispatcher.Dispatch<Cart, GetCartByOwnerIdQuery>(new GetCartByOwnerIdQuery(member.Guid)); return this.Json(cart, JsonRequestBehavior.AllowGet); }
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(); }
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 PartyHireInformationViewModel(Address address, Order order, Vintage.Rabbit.Parties.Entities.Party party) : base(address) { this.DeliveryCost = Constants.HireDeliveryCost.ToString("C0"); this.IsDelivery = order.Items.Any(o => o.Product.Type == ProductType.Delivery && o.Product.Title == "Pickup Hire Delivery") || order.Items.Any(o => o.Product.Type == ProductType.Delivery && o.Product.Title == "Dropoff Hire Delivery"); if(party != null) { this.PartyDate = party.PartyDate; } if (address != null) { this.PhoneNumber = address.PhoneNumber; } }
public InvitationViewModel(Order order, Vintage.Rabbit.Parties.Entities.Party party) { var invitation = order.Items.FirstOrDefault(o => ProductHelper.IsCustomisableInvitation(o.Product)); if(invitation != null && invitation.Product is IProduct && (invitation.Product as IProduct).Images.Any()) { this.InvitationImage = (invitation.Product as IProduct).Images.First().SecureUrl; } if(party != null) { this.ChildsName = party.ChildsName; this.Age = party.Age; this.PartyDate = party.PartyDate; this.PartyTime = party.PartyTime; this.PartyAddress = party.PartyAddress; this.RSVPDetails = party.RSVPDetails; } }
public ActionResult Login(LoginViewModel login, Cart cart, Order order) { if (this.ModelState.IsValid) { LoginResult result = this._loginProvider.Login(this.Request.GetOwinContext().Authentication, login.Email, login.Password, login.RememberMe); if(result.Successful) { if(cart != null && cart.MemberId != result.Member.Guid) { // convert cart this._commandDispatcher.Dispatch(new ChangeCartsMemberGuidCommand(cart, result.Member.Guid)); } if (order != null && cart.MemberId != result.Member.Guid) { // convert order this._commandDispatcher.Dispatch(new ChangeOrdersMemberGuidCommand(order, result.Member.Guid)); } if (string.IsNullOrEmpty(login.ReturnUrl)) { return this.RedirectToRoute(Routes.Home); } else { return this.Redirect(login.ReturnUrl); } } else { this.ModelState.AddModelError("Email", "Invalid username or email. Please try again"); } } return this.Login(login.ReturnUrl); }
public ActionResult ShippingInformation(AddressViewModel viewModel, Order order, Member member) { if (this.ModelState.IsValid) { Address shippingAddress = this._addressProvider.SaveShippingAddress(member, viewModel); this._commandDispatcher.Dispatch<AddShippingAddressCommand>(new AddShippingAddressCommand(order, shippingAddress)); return this.RedirectToRoute(Routes.Checkout.PaymentInfo); } return this.View("ShippingInformation", viewModel); }
public ActionResult PayPalSuccess(Order order, Member member, Guid paypalPaymentGuid, string token, string PayerID) { PayPalPayment payment = this._paypalService.Success(order, paypalPaymentGuid, token, PayerID); if(payment.Status == Payment.Enums.PayPalPaymentStatus.Completed) { return this.RedirectToRoute(Routes.Checkout.Complete); } else if(payment.Status == PayPalPaymentStatus.Error) { this.ModelState.AddModelError("Error", payment.Errors.First().ErrorMessage); } return this.PaymentInfo(order, member, PaymentMethod.PayPal); }
public ActionResult PayPalCancel(Order order, Guid paypalPaymentGuid, string token) { this._paypalService.Cancel(order, paypalPaymentGuid, token); return this.RedirectToRoute(Routes.Checkout.PaymentInfo); }
public ActionResult PayPal(Order order) { string url = this._paypalService.Checkout(order); return this.Redirect(url); }
public ActionResult Complete(Order order) { OrderViewModel viewModel = new OrderViewModel(order); return this.View("Complete", viewModel); }
public OrderViewModel(Order order) { this.OrderItems = order.Items.Select(o => new OrderItemViewModel(o)).ToList(); this.Total = order.Total.ToString("C2"); this.OrderNumber = order.Id.ToString("D5"); }
public ActionResult Summary(Order order) { OrderViewModel viewModel = new OrderViewModel(order); return this.PartialView("Summary", viewModel); }
public ActionResult Index(Member member, Order order, Cart cart, HireDatesViewModel hireDates) { if (this.HttpContext.User.Identity.IsAuthenticated) { Guid orderGuid = Guid.NewGuid(); if (order == null) { this._commandDispatcher.Dispatch(new AddCartItemsToOrderCommand(orderGuid, member, cart, hireDates.PartyDate)); } else { orderGuid = order.Guid; } return this.RedirectToRoute(Routes.Checkout.CustomisedInvitations, new { orderGuid = orderGuid }); } return this.LoginRegister(null); }
public ActionResult Guest(Member member, Order order, Cart cart, HireDatesViewModel hireDates) { this._commandDispatcher.Dispatch(new RegisterGuestCommand(member.Guid)); Guid orderGuid = Guid.NewGuid(); if (order == null) { this._commandDispatcher.Dispatch(new AddCartItemsToOrderCommand(orderGuid, member, cart, hireDates.PartyDate)); } else { orderGuid = order.Guid; } return this.RedirectToRoute(Routes.Checkout.CustomisedInvitations, new { orderGuid = orderGuid }); }
public ActionResult CustomisedInvitations(InvitationViewModel viewModel, Order order, Member member) { if (this.ModelState.IsValid) { AddInvitationDetailsCommand command = new AddInvitationDetailsCommand(order, viewModel.PartyDate.Value, viewModel.ChildsName, viewModel.Age, viewModel.PartyTime, viewModel.PartyAddress, viewModel.RSVPDetails, member); this._commandDispatcher.Dispatch(command); return this.RedirectToRoute(Routes.Checkout.PartyHireInformation); } return this.CustomisedInvitations(order, member); }
public ActionResult CustomisedInvitations(Order order, Member member) { if (order.Items.Any(o => ProductHelper.IsCustomisableInvitation(o.Product))) { Party party = this._queryDispatcher.Dispatch<Party, GetPartyByOrderGuidQuery>(new GetPartyByOrderGuidQuery(order.Guid)); InvitationViewModel viewModel = new InvitationViewModel(order, party); return this.View("CustomisedInvitations", viewModel); } return this.RedirectToRoute(Routes.Checkout.PartyHireInformation); }
public ActionResult CreditCardComplete(Order order, Member member, string AccessCode) { var result = this._creditCardService.CompletePayment(order, AccessCode); if(result.Successful) { return this.RedirectToRoute(Routes.Checkout.Complete); } else { this.ModelState.AddModelError("Error", result.ErrorMessage); } return this.PaymentInfo(order, member, PaymentMethod.CreditCard); }
public SaveOrderMessage(Order Order) { this.Order = Order; }
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); }
public ActionResult PartyHireInformation(PartyHireInformationViewModel viewModel, Order order, Member member, bool isBillingDetailsTheSame = false) { if (viewModel.IsDelivery && !this.ModelState.IsValid) { return this.PartyHireInformation(order, member); } this._commandDispatcher.Dispatch(new CreatePartyCommand(order, viewModel.PartyDate.Value, member)); if (viewModel.IsDelivery) { Address deliveryAddress = this._addressProvider.SaveDeliveryAddress(member, viewModel, viewModel.PhoneNumber); this._commandDispatcher.Dispatch(new AddDeliveryAddressCommand(order, deliveryAddress, true, true)); this._commandDispatcher.Dispatch(new AddPartyAddressCommand(order, deliveryAddress, member)); if (isBillingDetailsTheSame) { Address billingAddress = this._addressProvider.SaveBillingAddress(member, viewModel, null); this._commandDispatcher.Dispatch<AddBillingAddressCommand>(new AddBillingAddressCommand(order, billingAddress)); } } else { this._commandDispatcher.Dispatch(new RemoveDeliveryAddressCommand(order)); } return this.RedirectToRoute(Routes.Checkout.BillingInformation); }
public BillingAddressViewModel(Member member, Order order) : this(member, order, null) { }
public ActionResult PaymentInfo(Order order, Member member, PaymentMethod? paymentMethod = null) { PaymentInformationViewModel viewModel = new PaymentInformationViewModel(); viewModel.PaymentMethod = paymentMethod; var ewayAccess = this._creditCardService.GetEwayAccessCode(order); if(ewayAccess != null) { viewModel.EwayUrl = ewayAccess.FormActionUrl; viewModel.EwayAccessCode = ewayAccess.AccessCode; } if(order.Status == Orders.Enums.OrderStatus.Error) { viewModel.Error = "Sorry we are unable to process your payment. Please try again"; } return this.View("PaymentInfo", viewModel); }
public ActionResult OrderSummary(Order order) { return this.PartialView("OrderSummary", new OrderViewModel(order)); }
public ActionResult CheckOrderAvailability(Order order, HireDatesViewModel hireDates) { IList<IOrderItem> unavailableOrderItems = this._queryDispatcher.Dispatch<IList<IOrderItem>, GetUnavailableOrderItemsQuery>(new GetUnavailableOrderItemsQuery(order, hireDates.PartyDate)); IList<OrderItemViewModel> orderItems = unavailableOrderItems.Select(o => new OrderItemViewModel(o)).ToList(); return this.PartialView("OrderAvailability", orderItems); }
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); }
public InvoiceEmailViewModel(Order order) { this.Total = order.Total.ToString("C"); this.OrderItems = order.Items.Select(o => new OrderItemViewModel(o)).ToList(); this.PaymentMethod = (order.PaymentMethod == Payment.Enums.PaymentMethod.PayPal ? "PayPal" : "credit card"); }