public async Task <string> WriteBill(Bill bill)
        {
            var users = storageManager.GetChatUsers(bill.ChatId);

            string commentBody = "Amount: " + bill.AmountString + "\nSelected Users: " + string.Join(", ", users.Where(u => bill.SharedWith.Contains(u.Id)).Select(u => u.LastName + ' ' + u.FirstName)) + "\nCreated By: " + users.FirstOrDefault(u => u.Id == bill.CreatedBy).LastName + ' ' + users.FirstOrDefault(u => u.Id == bill.CreatedBy).FirstName;
            string commentUrl  = await CreateComment("16", commentBody);

            return(commentUrl);
        }
Example #2
0
        private async Task <Message> GenerateResponse(Bill bill, ITelegramBotClient client,
                                                      bool modifyExistingMessage = false)
        {
            MessageResponseDelegate responseDelegate = async(message, replyMarkup) =>
            {
                if (!modifyExistingMessage)
                {
                    return(await client.SendTextMessageAsync(bill.ChatId, message, false, false, 0, replyMarkup));
                }
                try
                {
                    return
                        (await
                         client.EditMessageTextAsync(bill.ChatId, bill.MessageId, message, ParseMode.Default, false,
                                                     replyMarkup));
                }
                catch (Exception)
                {
                    return(null);
                }
            };
            var users = storageManager.GetChatUsers(bill.ChatId);

            switch (bill.CurrentStatus)
            {
            case Bill.Status.SetAmountIntegeral:
            case Bill.Status.SetAmountFractional:
                return(await responseDelegate("Amount: " + bill.AmountString, KeyboardMarkupHelpers.CreateDigitInlineKeyboardMarkup(command)));

            case Bill.Status.SetSharedWith:
                return(await responseDelegate("Amount: " + bill.Amount + "\nSelected Users:",
                                              KeyboardMarkupHelpers.CreateUserSelectionKeyboardMarkup(command, users, bill.SharedWith)));

            case Bill.Status.Sealed:
                return(await responseDelegate("Amount: " + bill.AmountString + "\nSelected Users: " + string.Join(", ", users.Where(u => bill.SharedWith.Contains(u.Id)).Select(u => u.LastName + ' ' + u.FirstName)) + "\nTestIssue: \n https://github.com/RoommateX/test/issues/16", null));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }