Esempio n. 1
0
        public string AdminMessage()
        {
            string MenuStatus = "Активно";

            int?Balance = 0;

            if (Enable == false)
            {
                MenuStatus = "Скрыто от пользователей";
            }
            if (Stock.Count > 0)
            {
                Balance = Stock.OrderByDescending(s => s.Id).FirstOrDefault().Balance;
            }

            if (Unit == null)
            {
                Unit = Connection.getConnection().Units.Where(u => u.Id == UnitId).FirstOrDefault();
            }

            try
            {
                return(Bot.BotMessage.Bold("Название: ") + Name + Bot.BotMessage.NewLine() +
                       Bot.BotMessage.Bold("Цена: ") + ProductPrice.Where(p => p.Enabled).OrderByDescending(o => o.Id).FirstOrDefault().ToString() + " / " + Unit.ShortName + Bot.BotMessage.NewLine() +
                       Bot.BotMessage.Bold("Категория: ") + Category.Name + Bot.BotMessage.NewLine() +
                       Bot.BotMessage.Bold("Описание: ") + Text + Bot.BotMessage.NewLine() +
                       Bot.BotMessage.Bold("В наличии: ") + Balance.ToString() + Bot.BotMessage.NewLine() +
                       Bot.BotMessage.Bold("В меню: ") + MenuStatus);
            }

            catch (Exception e)
            {
                return(String.Empty);
            }
        }
Esempio n. 2
0
        public override string ToString()
        {
            string StockStatus = String.Empty;

            const string StockStatusMany = "Много";

            const string StockStatusFew = "Мало";

            const string StockStatusOutOfStock = "Нет в наличии";

            const int Many = 5;

            if (Stock.Count > 0 && Stock.ElementAt(Stock.Count - 1) != null && Stock.ElementAt(Stock.Count - 1).Balance >= Many)
            {
                StockStatus = StockStatusMany;
            }

            if (Stock.Count > 0 && Stock.ElementAt(Stock.Count - 1) != null && Stock.ElementAt(Stock.Count - 1).Balance > 0 && Stock.ElementAt(Stock.Count - 1).Balance <= Many)
            {
                StockStatus = StockStatusFew;
            }

            if (Stock.Count > 0 && Stock.ElementAt(Stock.Count - 1) == null || Stock.Count > 0 && Stock.ElementAt(Stock.Count - 1) != null && Stock.ElementAt(Stock.Count - 1).Balance == 0)
            {
                StockStatus = StockStatusOutOfStock;
            }

            if (Stock.Count == 0)
            {
                StockStatus = StockStatusOutOfStock;
            }

            var price = ProductPrice.Where(p => p.Enabled).FirstOrDefault().ToString();

            return("Название: " + Name + Bot.BotMessage.NewLine() +
                   "Цена: " + ProductPrice.Where(p => p.Enabled).FirstOrDefault().ToString() + " / " + Unit.ShortName + Bot.BotMessage.NewLine() +
                   "Описание: " + Text + Bot.BotMessage.NewLine() +
                   "В наличии: " + StockStatus);
        }