Beispiel #1
0
        public async Task DoPossibleWithdraws()
        {
            var account = UserAccounts.GetAccount(Context.User);
            List <Investment> investments = InvestmentsManager.GetInvestments(account);

            if (investments.Count == 0)
            {
                await Context.Channel.SendMessageAsync("Nie posiadasz zadnych lokat.");
            }
            else
            {
                int cash = 0, investmentsDeleted = 0;
                foreach (var i in investments)
                {
                    if (DateTime.Now >= i.PaymentDate + i.InvestmentDuration)
                    {
                        account.Cash += i.MoneyToWithdraw;
                        cash         += i.MoneyToWithdraw;
                        InvestmentsManager.DeleteInvestment(i.ID);
                        investmentsDeleted++;
                    }
                }

                if (investmentsDeleted > 0)
                {
                    await Context.Channel.SendMessageAsync($"Wyplacono **{cash}** dudow z " +
                                                           $"**{investmentsDeleted}** lokat.");

                    UserAccounts.SaveAccounts();
                }
                else
                {
                    await Context.Channel.SendMessageAsync("Zadna z twoich lokat sie nie zakonczyla");
                }
            }
        }
Beispiel #2
0
        public async Task ShowUserInvestments()
        {
            var account = UserAccounts.GetAccount(Context.User);
            List <Investment> investments = InvestmentsManager.GetInvestments(account);

            if (investments.Count == 0)
            {
                await Context.Channel.SendMessageAsync("Nie posiadasz zadnych lokat.");
            }
            else
            {
                var embed = new EmbedBuilder();
                embed.WithTitle($"Lokaty {Context.User.Username}");
                embed.WithColor(Colors.AvalibleColors[(int)account.ActuallyColor].RightColor);

                foreach (var i in investments)
                {
                    embed.AddField($"[{i.ID}] Zalozono: `{i.PaymentDate}`", $"" +
                                   $"Wyplata: `{i.MoneyToWithdraw}` dudow. Koniec: `{i.PaymentDate+i.InvestmentDuration}`");
                }

                await Context.Channel.SendMessageAsync("", false, embed);
            }
        }