private void DisplayBasketDetails(BornBasket basket)
        {
            var currency = CurrencyService.GetCurrencyByCode(basket.CurrencyCode);

            CurrentLanguageId = basket.Language;
            MicrositeId       = basket.LastMicroSite;
            TotalSummary      = currency.Symbol + basket.Total.ToString("F");

            LoadMasterValues();

            ucBasketDisplay.AddMoreUrl    = ConfigurationManager.AppSettings["BornAddMoreTicketUrl"];
            ucBasketDisplay.ParentPage    = this;
            ucBasketDisplay.ShowActionRow = true;
            ucBasketDisplay.TotalString   = TotalSummary;

            var itemList = basket.BasketItems.Select(item => new BasketDisplayVm
            {
                TicketName   = item.ProductName + " - " + item.Microsite,
                Date         = GetTranslation("OpenDayTicket"),
                Quantity     = item.Quantity,
                Title        = item.TicketType.ToString(),
                TotalSummary = currency.Symbol + item.Total
            }).ToList();

            ucBasketDisplay.DataSource = itemList;
        }
Пример #2
0
        public virtual bool IsBornBasketValid(BornBasket brnBasket)
        {
            var currencyId = _currencyService.GetCurrencyGuidByCode(brnBasket.CurrencyCode);

            //we cannot persist a basket without that external guid
            if (string.IsNullOrEmpty(brnBasket.ExternalCookieValue))
            {
                return(false);
            }

            //validate currency in basket
            if (currencyId == Guid.Empty)
            {
                //log issue and return false;
                return(false);
            }

            brnBasket.CurrencyId = currencyId;

            //validate all tickets in basket
            foreach (var basketItem in brnBasket.BasketItems)
            {
                var ticket = _ticketService.GetTicketByEcrSysId(basketItem.MainSku);

                if (ticket == null)
                {
                    //log invalid ticket and return
                    LoggerService.LogItem("BasketService => IsBornBasketValid(). Invalid ticket found in basket ticketid: " + basketItem.Sku + " basket external session id: " + brnBasket.ExternalCookieValue);
                    return(false);
                }
                basketItem.TicketId = ticket.Id;
            }

            return(true);
        }
        //*** make sure you padd cookievalue here.
        public BornBasket GetExternalBasketByCookie(string cookieValue)
        {
            BornBasket basket = null;

            try
            {
                var finalUrl = string.Format(_fullUrl, cookieValue);

                Log("Retrieving basket for external sessionid: " + cookieValue + " url " + finalUrl);

                var client = new HttpClient();
                var task   = client.GetAsync(finalUrl)
                             .ContinueWith((taskwithresponse) =>
                {
                    var response   = taskwithresponse.Result;
                    var jsonString = response.Content.ReadAsStringAsync();
                    jsonString.Wait();

                    LoggerService.LogBornBasket(jsonString.Result, cookieValue);  //log this to db.

                    basket = JsonConvert.DeserializeObject <BornBasket>(jsonString.Result);
                });

                task.Wait();
            }
            catch (Exception ex)
            {
                //log exception here.
                LoggerService.LogItem("External basket retrieval failed: external sessionid " + cookieValue + Environment.NewLine + ex.Message, cookieValue);
            }

            return(basket);
        }
Пример #4
0
        public virtual Guid PersistBasket(BornBasket brnBasket)
        {
            //make sure basket is valid before persisting it.
            //if(!IsBornBasketValid(brnBasket))
            // return Guid.Empty;

            var itemCount = 0;

            var basket = new Basket
            {
                DateCreated         = DateTime.Now,
                CurrencyId          = brnBasket.CurrencyId,
                Total               = brnBasket.Total,
                DiscountValue       = brnBasket.Discount,
                ExternalCookieValue = brnBasket.ExternalCookieValue,
                ExternalCoupon      = brnBasket.Coupon,
                PurchaseLanguage    = brnBasket.Language
            };

            foreach (var item in brnBasket.BasketItems)
            {
                basket.BasketLines.Add(
                    new BasketLine
                {
                    TicketId              = item.TicketId,
                    FixedDateTicket       = false,
                    TicketType            = item.TicketType.ToString(),
                    TicketQuantity        = item.Quantity,
                    DateAdded             = DateTime.Now,
                    Price                 = item.UnitCost,
                    Discount              = item.Discount,
                    LineTotal             = item.Total,
                    EcrProductDimensionId = item.ProductDimensionUid,
                    ExternalCoupon        = item.Coupon,
                    ExternalOrder         = itemCount
                });

                itemCount++;
            }

            _repository.Add(basket);

            return(basket.Id);
        }