Exemplo n.º 1
0
        public SellerStats GetSellerStats(Guid sellerId)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sellerStats = new SellerStats();

                var topProductInfo = GetTopProduct(sellerId);

                if (topProductInfo != null)
                {
                    var topProduct = _productRepo.GetProductById(topProductInfo.MostSoldProduct);
                    sellerStats.TopProduct           = topProduct;
                    sellerStats.TopProductAmountSold = topProductInfo.MostSoldAmount;
                }

                var topMonthProductInfo = GetTopProductForMonth(sellerId);

                if (topMonthProductInfo != null)
                {
                    var topMonthProduct = _productRepo.GetProductById(topMonthProductInfo.MostSoldProduct);
                    sellerStats.TopMonthProduct           = topMonthProduct;
                    sellerStats.TopMonthProductAmountSold = topMonthProductInfo.MostSoldAmount;
                }

                var totalSales = GetTotalSales(sellerId);
                var monthSales = GetTotalSalesForTheMonth(sellerId);
                sellerStats.TotalSales = totalSales;
                sellerStats.MonthSales = monthSales;

                return(sellerStats);
            }
        }
Exemplo n.º 2
0
 public SellerStats SellerSts(Guid SellerID)
 {
     SellerStats response = new SellerStats();
     response.numSales = 0;
     response.sold = 0;
     response.owed = 0;
     var giftCards = from gc in db.GiftCards where gc.SellerID == SellerID.ToString() where gc.TotalIn != 0 select gc;
     if (giftCards.Count() > 0)
     {
         foreach (GiftCard gc in giftCards)
         {
             response.numSales += 1;
             response.sold += gc.TotalIn;
             if (gc.SalesDealRate != null)
             {
                    response.owed += Math.Round(gc.TotalIn / 100 * gc.SalesDealRate, 2);
             }
         }
     }
     return response;
 }