コード例 #1
0
        // Load all the promotions in the Promos collection. Can load a specified promo or all of them
        /// <summary>
        /// Method to load all promos
        /// </summary>
        /// <param name="optPromoId">PromoID</param>
        /// <returns>Promos</returns>
        public Promos Load_Promos(string optPromoId)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,PromoManager,Load_Promos,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var promos = CacheManager.GetPromosForPromoId(optPromoId);

            if (promos != null && promos.Count != 0)
            {
                return(promos);
            }
            promos = new Promos();
            var store        = CacheManager.GetStoreInfo();
            var offSet       = store?.OffSet ?? 0;
            var none         = _resourceManager.GetResString(offSet, 347);
            var promoHeaders = _promoService.GetPromoHeadersForToday(optPromoId);

            foreach (var promoHeader in promoHeaders)
            {
                var promo      = promoHeader;
                var promoLines = new Promo_Lines();

                //promo.MaxLink = _promoService.GetMaxLink(promo.PromoID);
                //var noOfLinks = _promoService.GetNumberOfLinks(promo.PromoID);
                //foreach (var noOfLink in noOfLinks)
                //{
                //    if (noOfLink > 1)
                //    {
                //        promo.MultiLink = true;
                //        break;
                //    }
                //}

                var promoDetails = _promoService.GetPromoLines(promo.PromoID, none);
                foreach (var promoDetail in promoDetails)
                {
                    promoLines.AddLine(promoDetail, "");
                }
                promo.Promo_Lines = promoLines;
                promos.Add(promo, promo.PromoID);
            }
            Performancelog.Debug($"End,PromoManager,Load_Promos,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            CacheManager.AddPromos(optPromoId, promos);
            return(promos);
        }