public override BotMessage BuildMsg()
        {
            db = new MarketBotDbContext();

            StockList = db.Stock.Where(s => s.ProductId == ProductId).Include(s => s.Product).OrderByDescending(s => s.Id).ToList();

            Pages = base.BuildDataPage <Stock>(StockList, base.PageSize);

            base.MessageReplyMarkup = base.PageNavigatorKeyboard <Stock>(Pages, Bot.AdminModule.AdminBot.ViewStockHistoryProdCmd, Bot.AdminModule.AdminBot.ModuleName, base.BackToAdminPanelBtn(), Argument: ProductId);

            if (Pages != null && Pages.Count > 0 && Pages[SelectPageNumber] != null)
            {
                var page = Pages[SelectPageNumber];

                int counter = 0;

                base.TextMessage = base.BlueRhombus + " " + StockList.FirstOrDefault().Product.Name + NewLine() + "Всего записей:" + StockList.Count.ToString() +
                                   NewLine() + "Страница " + SelectPageNumber.ToString() + " из " + Pages.Count.ToString() + NewLine() + NewLine();

                foreach (var stock in page)
                {
                    base.TextMessage += "Дата: " + stock.DateAdd.ToString() + " | Было " + (stock.Balance - stock.Quantity).ToString()
                                        + " | Изменение: " + stock.Quantity.ToString() + " | Стало: " + stock.Balance.ToString() + " | комментарий: " + stock.Text + NewLine();

                    counter++;
                }
            }

            return(this);
        }
Esempio n. 2
0
 private void AddStockToSaleMethod()
 {
     try
     {
         if (SelectedStock != null)
         {
             SelectedStock.SaleValue    = StockItemSaleValue;
             TransactionDetails.Amount += SelectedStock.SaleValue;
             StockSaleList.Add(_SelectedStock);
             StockList.Remove(StockList.FirstOrDefault(x => x.Stockid == SelectedStock.Stockid));
             SelectedStock      = new skStock();
             StockItemSaleValue = 0;
         }
     }
     catch (Exception E)
     {
         ExepionLogger.Logger.LogException(E);
         ExepionLogger.Logger.Show(E);
     }
 }