Esempio n. 1
0
        /// <summary>
        /// Print current balance to slack publicly.
        /// </summary>

        private async Task HandleShowBalanceAction(SlashCommand command)
        {
            var balanceBook = await foodService.GetBalanceBook();

            if (balanceBook == null)
            {
                throw new BadRequestException("No balance is tracked.");
            }

            await SendCommandResponse(command, SlackFormatter.BuildBalanceMessage(balanceBook));
        }
Esempio n. 2
0
        /// <summary>
        /// Finish the order, update balance and publish the updated balance to slack along with closed order message.
        /// </summary>

        private async Task HandleFinalizeOrderAction(SlashCommand command)
        {
            var(finishedOrder, updatedBalance) = await foodService.FinishOrder();

            var responseBlocks = new List <Block>();

            responseBlocks.AddRange(SlackFormatter.BuildOrderMessage(finishedOrder));
            responseBlocks.AddRange(SlackFormatter.BuildBalanceMessage(updatedBalance));

            await SendCommandResponse(command, responseBlocks);
        }
Esempio n. 3
0
        /// <summary>
        /// Reopen last finished order, revert balance and notify slack.
        /// </summary>
        private async Task HandleReopenOrderAction(SlashCommand command)
        {
            var(reopenedOrder, updatedBalance) = await foodService.ReopenOrder();
            await SendPublicResponse(command, "Order reopened, reverting last balance changes.");

            var responseBlocks = new List <Block>();

            responseBlocks.AddRange(SlackFormatter.BuildBalanceMessage(updatedBalance));
            responseBlocks.AddRange(SlackFormatter.BuildOrderMessage(reopenedOrder));

            await SendCommandResponse(command, responseBlocks);
        }