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 Hire(string themeName, Models.Hire.HireDatesViewModel hireDates, Models.Hire.HireAvailabilityViewModel hireAvailability, Member member, bool postcodeChecked = false, bool changePostcode = false) { Theme theme = this._queryDispatcher.Dispatch<IList<Theme>, GetThemesQuery>(new GetThemesQuery()).First(o => o.Title.ToUrl() == themeName); if (!hireAvailability.IsValidPostcode) { if (string.IsNullOrEmpty(hireAvailability.Postcode)) { return this.PartialView("PostcodeCheck", new PostcodeCheckViewModel(theme)); } return this.PartialView("HireUnavailable"); } if (!hireDates.PartyDate.HasValue || changePostcode) { return this.PartialView("AvailabilityCheck", new PartyDatePickerViewModel(theme)); } else { var products = this._queryDispatcher.Dispatch<IList<Product>, GetProductsByGuidsQuery>(new GetProductsByGuidsQuery(this.GetProductGuids(theme))); ThemeViewModel viewModel = new ThemeViewModel(theme, products); if (this._queryDispatcher.Dispatch<bool, CanAddThemeToCartQuery>(new CanAddThemeToCartQuery(member.Guid, theme.Guid, hireDates.PartyDate.Value))) { ViewBag.PartyDate = hireDates.PartyDate.Value; return this.PartialView("AddToCart", viewModel); } return this.PartialView("Unavailable", viewModel); } }
public ActionResult AvailabilityCheck(Member member, Cart cart, Guid productGuid, HireDatesViewModel hireDates, HireAvailabilityViewModel hireAvailability, bool postcodeChecked = false) { Product product = this._queryDispatcher.Dispatch<Product, GetProductByGuidQuery>(new GetProductByGuidQuery(productGuid)); if (!hireAvailability.IsValidPostcode) { if (string.IsNullOrEmpty(hireAvailability.Postcode)) { return this.PartialView("PostcodeCheck", new PostcodeCheckViewModel(product)); } return this.PartialView("HireUnavailable"); } if (hireDates.PartyDate.HasValue) { int availableInventory = this._queryDispatcher.Dispatch<int, GetInventoryCountCanAddToCartQuery>(new GetInventoryCountCanAddToCartQuery(member.Guid, productGuid, hireDates.PartyDate.Value)); bool inCart = cart.Items.Any(o => o.Product.Guid == productGuid); return this.PartialView("AddToCart", new HireAddProductToCartViewModel(product, availableInventory, inCart, hireDates.PartyDate.Value)); } ViewBag.PostcodeChecked = postcodeChecked; return this.PartialView("AvailabilityCheck", new HireProductViewModel(product, hireDates)); }
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 Address SaveShippingAddress(Member member, AddressViewModel viewModel) { Guid addressId = viewModel.Guid; Address address = new Address(member.Guid, AddressType.Shipping, addressId, viewModel.Address, viewModel.SuburbCity, viewModel.State, viewModel.Postcode.Value, viewModel.FirstName, viewModel.LastName, null, null, viewModel.CompanyName); this._commandDispatcher.Dispatch<SaveAddressCommand>(new SaveAddressCommand(address)); return address; }
public Address SaveDeliveryAddress(Member member, AddressViewModel viewModel, string phoneNumber) { Guid addressId = viewModel.Guid; Address address = new Address(member.Guid, AddressType.Delivery, addressId, viewModel.Address, viewModel.SuburbCity, viewModel.State, viewModel.Postcode.Value, viewModel.FirstName, viewModel.LastName, null, phoneNumber, viewModel.CompanyName); this._commandDispatcher.Dispatch<SaveAddressCommand>(new SaveAddressCommand(address)); return address; }
public MemberViewModel(Member member) { this.Id = member.Id; this.Guid = member.Guid; this.Email = member.Email; this.Password = member.Password; this.FirstName = member.FirstName; this.LastName = member.LastName; this.Roles = member.Roles; }
public ActionResult AddToCartForm(Member member, Cart cart, Guid productGuid) { int availableInventory = this._queryDispatcher.Dispatch<int, GetInventoryCountCanAddToCartQuery>(new GetInventoryCountCanAddToCartQuery(member.Guid, productGuid)); bool inCart = cart.Items.Any(o => o.Product.Guid == productGuid); Product product = this._queryDispatcher.Dispatch<Product, GetProductByGuidQuery>(new GetProductByGuidQuery(productGuid)); AddProductToCartViewModel viewModel = new AddProductToCartViewModel(product, availableInventory, inCart); return this.PartialView("AddToCart", viewModel); }
public ActionResult AddTheme(string name, Guid themeGuid, Member member, HireDatesViewModel dates) { if (dates.PartyDate.HasValue) { Theme theme = this._queryDispatcher.Dispatch<Theme, GetThemeByGuidQuery>(new GetThemeByGuidQuery(themeGuid)); this._commandDispatcher.Dispatch(new AddThemeToCartCommand(member.Guid, theme, dates.PartyDate.Value)); } 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 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 LoggedInMember(Member member) { return this.Content(member.Email); }
public BillingAddressViewModel(Member member, Order order) : this(member, order, null) { }
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 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 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 Save(ThemeViewModel viewModel, Member member) { if(this.ModelState.IsValid) { Theme theme = this._queryDispatcher.Dispatch<Theme, GetThemeByGuidQuery>(new GetThemeByGuidQuery(viewModel.Guid)); if(theme==null) { theme = new Theme(viewModel.Guid); } theme.Title = viewModel.Title; theme.Description = viewModel.Description; theme.IncludedItems = viewModel.IncludedItems; theme.Cost = viewModel.Cost.Value; theme.SEOTitle = viewModel.SEOTitle; theme.SEOKeywords = viewModel.SEOKeywords; theme.SEODescription = viewModel.SEODescription; this._commandDispatcher.Dispatch(new SaveThemeCommand(theme, member)); return this.RedirectToRoute(Routes.Themes.Edit, new { themeGuid = viewModel.Guid }); } return this.View("Add", viewModel); }
public ActionResult CheckProductAvailability(Member member, Guid productGuid, HireDatesViewModel hireDates) { if (hireDates.PartyDate.HasValue) { bool available = this._queryDispatcher.Dispatch<int, GetInventoryCountCanAddToCartQuery>(new GetInventoryCountCanAddToCartQuery(member.Guid, productGuid, hireDates.PartyDate.Value)) > 0; return this.Json(new { Available = available }, JsonRequestBehavior.AllowGet); } return this.Json(new { Available = false }, JsonRequestBehavior.AllowGet); }
public ActionResult Remove(Guid cartItemId, Member member) { this._commandDispatcher.Dispatch(new RemoveCartItemCommand(member.Guid, cartItemId)); Cart cart = this._queryDispatcher.Dispatch<Cart, GetCartByOwnerIdQuery>(new GetCartByOwnerIdQuery(member.Guid)); return this.Json(cart, JsonRequestBehavior.AllowGet); }
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 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 SaveMemberMessage(Member member) { this.Member = member; }
public ActionResult RemoveProduct(Guid guid, Guid themeImageGuid, Guid themeProductGuid, Member member) { this._commandDispatcher.Dispatch(new RemoveProductFromThemeCommand(guid, themeImageGuid, themeProductGuid, member)); return this.RedirectToRoute(Routes.Themes.Products); }
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 ActionResult SaveProduct(Guid guid, AddProductToThemeImageViewModel viewModel, Member member) { if (this.ModelState.IsValid) { this._commandDispatcher.Dispatch(new AddProductToThemeCommand(guid, viewModel.ThemeImageGuid, viewModel.ThemeProductGuid, viewModel.ProductGuid.Value, viewModel.Qty.Value, viewModel.X.Value, viewModel.Y.Value, member)); } return this.RedirectToRoute(Routes.Themes.Products); }
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); }