예제 #1
0
        /*
         * [HttpGet("catalog/generalstats/")]
         * public CatalogStats GeneralStats(int page = 1)
         * {
         *  CatalogStats cs = new CatalogStats();
         *
         *  cs.ProductCount = List(page).Select(x => x.id).Count(); ;
         *
         *  cs.UnitCount = List(page).SelectMany(x => x.units).Count();
         *
         *  cs.ProductsWithOneUnit = from iets in List(page)
         *                           where iets.units.Length == 1
         *                           select iets.id;
         *
         *  return cs;
         * }
         */


        /*
         * //[HttpGet("catalog/generalstats/")]
         * public async Task<CatalogStats> GeneralStats(int page = 1)
         * {
         *  CatalogStats cs = new CatalogStats();
         *
         *  cs.ProductCount = List(page).Select(x => x.id).Count(); ;
         *
         *  cs.UnitCount = List(page).SelectMany(x => x.units).Count();
         *
         *  cs.ProductsWithOneUnit = from iets in List(page)
         *                           where iets.units.Length == 1
         *                           select iets.id;
         *
         *  return await Task.Run(() => cs);
         * }
         */

        public CatalogStats GeneralStats()
        {
            var stats = new CatalogStats();

            stats.ProductCount        = catalogContext.Product.Count();
            stats.UnitCount           = catalogContext.Product.SelectMany(x => x.Units).Count();
            stats.ProductsWithOneUnit = catalogContext.Product.Where(x => x.Units.Count() == 1).Select(x => x.Id).ToList();
            return(stats);
        }
예제 #2
0
        public async Task <CatalogStats> GeneralStatsAsync()
        {
            var stats = new CatalogStats();

            stats.ProductCount = await catalogContext.Product.CountAsync();

            stats.UnitCount = await catalogContext.Product.SelectMany(x => x.Units).CountAsync();

            stats.ProductsWithOneUnit = await catalogContext.Product.Where(x => x.Units.Count() == 1).Select(x => x.Id).ToListAsync();

            return(stats);
        }
예제 #3
0
 public StatsReponse(CatalogStats stats)
 {
     Stats = stats;
 }
예제 #4
0
 private bool onStatsResponse(CatalogServiceProxyEvents.StatsReponse evt)
 {
     if (isStatsLoading)
     {
         isStatsLoading = false;
         if (Model.State == CatalogState.StatsView)
         {
             shopScroller.ClearScroller();
             stats = evt.Stats;
             if (TotalSold != null)
             {
                 TotalSold.text = stats.TotalItemsSold.ToString();
             }
             if (BestSellerSold != null)
             {
                 try
                 {
                     BestSellerSold.text = stats.StatsItem.numberSold.ToString();
                     if (stats.TotalItemsSold < stats.StatsItem.numberSold)
                     {
                         BestSellerSold.text = stats.TotalItemsSold.ToString();
                     }
                 }
                 catch (Exception ex)
                 {
                     Log.LogErrorFormatted(this, "An error occured when setting best seller sold text. Message: {0}", ex.Message);
                 }
             }
             if (TotalSubmitted != null)
             {
                 TotalSubmitted.text = stats.TotalItemsPurchased.ToString();
             }
             if (stats.StatsData != null)
             {
                 DCustomEquipment[] outfit;
                 if (stats.StatsItem.equipment.parts == null || stats.StatsItem.equipment.parts.Length == 0)
                 {
                     outfit = new DCustomEquipment[0];
                 }
                 else
                 {
                     DCustomEquipment dCustomEquipment = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(stats.StatsItem.equipment);
                     outfit = new DCustomEquipment[1] {
                         dCustomEquipment
                     };
                 }
                 AvatarDetailsData avatarDetailsData = new AvatarDetailsData();
                 avatarDetailsData.Init(outfit);
                 if (this.avatarDetailsData != null)
                 {
                     avatarDetailsData.BodyColor = this.avatarDetailsData.BodyColor;
                 }
                 AvatarRenderTextureComponent.RenderAvatar(avatarDetailsData);
                 shopScroller.items         = stats.StatsData;
                 shopScroller.filteredItems = stats.StatsData;
                 shopScroller.GenerateScrollData(stats.StatsData);
                 for (int i = 0; i < shopScroller.numShopRows; i++)
                 {
                     shopScroller.Scroller.AddElement(1);
                 }
                 shopScroller.isShopScrollInitialized = true;
                 shopScroller.lastNumShopRows         = shopScroller.numShopRows;
             }
         }
     }
     return(false);
 }