コード例 #1
0
        private IMenu GetNewReceiptSelectConsumersMenu(UserMessageInfo userMessageInfo, AddReceiptQueryData data)
        {
            Builder builder = new Builder();

            for (int i = 0; i < userMessageInfo.Customers.Length; i++)
            {
                if (i % 3 == 0)
                {
                    builder.AddLine();
                }

                var customer = userMessageInfo.Customers[i];

                // Не отображаем того, кто покупал.
                if (customer.Id == data.SelectedCustomerId)
                {
                    continue;
                }

                string query = _queryDataSerializer.EncodeBase64(new AddReceiptQueryData
                {
                    Version             = AddReceiptQueryData.ServerVersion,
                    ChatToken           = userMessageInfo.Group.ChatToken,
                    ReceiptId           = data.ReceiptId,
                    MenuType            = data.MenuType,
                    SelectedConsumerIds = data.SelectedConsumerIds.ToArray(),
                    SelectedCustomerId  = data.SelectedCustomerId,
                    TargetId            = customer.Id,
                }, MenuType.NewReceiptSelectConsumers);

                builder.AddButton(customer.Caption + (data.SelectedConsumerIds.Contains(customer.Id) ? " ☑" : ""), query);
            }

            builder.AddLine();

            if (data.SelectedConsumerIds.Any())
            {
                builder.AddButton("Применить", _queryDataSerializer.EncodeBase64(new AddReceiptQueryData
                {
                    Version             = AddReceiptQueryData.ServerVersion,
                    ChatToken           = userMessageInfo.Group.ChatToken,
                    ReceiptId           = data.ReceiptId,
                    MenuType            = MenuType.NewReceiptAdd,
                    SelectedConsumerIds = data.SelectedConsumerIds,
                    SelectedCustomerId  = data.SelectedCustomerId.Value,
                    TargetId            = null,
                }, MenuType.NewReceiptSelectConsumers));
            }

            builder.AddButton("Отменить", _queryDataSerializer.EncodeBase64(new AddReceiptQueryData
            {
                Version   = AddReceiptQueryData.ServerVersion,
                ChatToken = userMessageInfo.Group.ChatToken,
                ReceiptId = data.ReceiptId,
                MenuType  = MenuType.NewReceiptCancel
            }, MenuType.NewReceiptSelectConsumers));

            var markUp = builder.Build();

            return(new TelegramMenu
            {
                MenuType = MenuType.NewReceiptSelectCustomer,
                Markup = markUp,
            });
        }
コード例 #2
0
        private IMenu GetNewReceiptSelectCustomerMenu(UserMessageInfo userMessageInfo, AddReceiptQueryData data)
        {
            Builder builder = new Builder();

            for (int i = 0; i < userMessageInfo.Customers.Length; i++)
            {
                if (i % 3 == 0)
                {
                    builder.AddLine();
                }

                var    customer = userMessageInfo.Customers[i];
                string query    = _queryDataSerializer.EncodeBase64(new AddReceiptQueryData
                {
                    Version             = AddReceiptQueryData.ServerVersion,
                    ChatToken           = userMessageInfo.Group.ChatToken,
                    ReceiptId           = data.ReceiptId,
                    MenuType            = MenuType.NewReceiptSelectCustomer,
                    SelectedConsumerIds = data.SelectedConsumerIds,
                    SelectedCustomerId  = data.TargetId,
                    TargetId            = customer.Id,
                }, MenuType.NewReceiptSelectCustomer);

                builder.AddButton(customer.Caption + (customer.Id == data.TargetId ? " ☑" : ""), query);
            }

            builder.AddLine();

            if (data.TargetId.HasValue)
            {
                builder.AddButton("Применить", _queryDataSerializer.EncodeBase64(new AddReceiptQueryData
                {
                    Version             = AddReceiptQueryData.ServerVersion,
                    ChatToken           = userMessageInfo.Group.ChatToken,
                    ReceiptId           = data.ReceiptId,
                    MenuType            = MenuType.NewReceiptSelectConsumers,
                    SelectedConsumerIds = data.SelectedConsumerIds,
                    SelectedCustomerId  = data.SelectedCustomerId.Value,
                    TargetId            = null,
                }, MenuType.NewReceiptSelectCustomer));
            }

            builder.AddButton("Отменить", _queryDataSerializer.EncodeBase64(new AddReceiptQueryData
            {
                Version   = AddReceiptQueryData.ServerVersion,
                ChatToken = userMessageInfo.Group.ChatToken,
                ReceiptId = data.ReceiptId,
                MenuType  = MenuType.NewReceiptCancel
            }, MenuType.NewReceiptSelectCustomer));

            var markUp = builder.Build();

            return(new TelegramMenu
            {
                MenuType = MenuType.NewReceiptSelectCustomer,
                Markup = markUp,
            });
        }