Example #1
0
        public virtual Order GetFullOrder(string orderId)
        {
            try
            {
                var order =
                    OrderRepository.GetSingle(
                        x => x.Id.ToString().Equals(orderId, StringComparison.CurrentCultureIgnoreCase));

                order.OrderLines =
                    OrderLineRepository.GetList(
                        x => x.OrderId.ToString().Equals(orderId, StringComparison.CurrentCultureIgnoreCase));

                order.Currency = CurrencyRepository.GetSingle(x => x.Id.Equals(order.CurrencyId));

                order.User = UserRepository.GetSingle(x => x.Id.Equals(order.UserId));

                return(order);
            }
            catch (Exception ex)
            {
                Log("Error getting full order: GetFullOrder() Id:" + orderId + Environment.NewLine + ex.Message);
            }

            return(null);
        }
Example #2
0
        public virtual Order CreateOrder(Session session, Basket basket, pci.BasketStatus basketStatus, string clientIpAddress, string languageId, string micrositeId)
        {
            try
            {
                Guid?currencyId        = new Guid(session.CurrencyId);
                var  currency          = CurrencyRepository.GetSingle(x => x.Id.Equals(currencyId));
                var  micrositeCurrency = GetCurrencyFromMicrositeId(micrositeId);
                var  user = UserRepository.GetSingle(x => x.Id == basket.UserId);

                var order = new Order
                {
                    PaymentMethod                 = basketStatus.card.type,
                    NumbViewPdf                   = 0,
                    OpenForPrinting               = true,
                    DatePdfLastViewed             = DateTime.Now,
                    UserId                        = user.Id,
                    UserName                      = user.Firstname + " " + user.Lastname,
                    EmailAddress                  = string.IsNullOrWhiteSpace(user.FriendlyEmail) ? user.Email : user.FriendlyEmail,
                    CurrencyId                    = currencyId,
                    LanguageId                    = languageId,
                    Total                         = basket.Total,
                    CcLast4Digits                 = basketStatus.card.number,
                    ClientIp                      = clientIpAddress,
                    WorldPayMerchantId            = basketStatus.merchant.merchantId,
                    GatewayReference              = basketStatus.merchant.gatewayref,
                    NameOnCard                    = basketStatus.card.name,
                    BasketId                      = basket.Id,
                    SessionId                     = session.Id,
                    TotalQuantity                 = basket.BasketLines.Sum(x => x.TicketQuantity),
                    IsMobileAppOrder              = false, //check how this is populated on old system.
                    DateCreated                   = LocalizationService.GetLocalDateTime(micrositeId),
                    FromNewCheckout               = true,
                    PurchaseMicrosite             = micrositeId,
                    PurchaseMicrositeCurrencyCode = micrositeCurrency.ISOCode
                };

                //populate order lines with existing baskets.
                foreach (var basketLine in basket.BasketLines)
                {
                    order.OrderLines.Add(ConvertBasketLineToOrderLine(basketLine, order.Id));
                }

                OrderRepository.Add(order);

                order.User     = user;
                order.Currency = currency;

                return(order);
            }
            catch (Exception ex)
            {
                Log(string.Format("Order Create Failed sessionid: {0} basketid:{1} {2} ", session.Id, basket.Id, ex.Message));
                return(null);
            }
        }