예제 #1
0
        public async Task PickMoreOrders(CoffeeService coffee, User user, string text, SlackResponse response)
        {
            if (!int.TryParse(text, out var count))
            {
                throw new NotWellFormedException();
            }
            if (count <= 0)
            {
                throw new NotWellFormedException();
            }

            var at = DateTime.Now;

            var picked = await coffee.PickMoreOrderAsync(count, at);

            if (picked.Count <= 0)
            {
                throw new NoOneToPickException();
            }

            var orders = await coffee.GetOrdersAsync(at);

            var candidatesCount = picked.Count + orders.Count(o => o.PickedAt <= DateTime.MinValue);
            var sb = new StringBuilder($"<추가 당첨자 명단> {candidatesCount}명 중에 {picked.Count}명").AppendLine();
            await sb.AppendOrders(coffee, picked);

            var responseText = sb.ToString();

            response
            .Ephemeral("추첨하였습니다")
            .InChannel(responseText, "manager")
            .InChannel(responseText, "user");
        }
예제 #2
0
        public async Task GetOrders(CoffeeService coffee, User user, string text, SlackResponse response)
        {
            var at     = DateTime.Now;
            var orders = await coffee.GetOrdersAsync(at);

            if (orders.Count <= 0)
            {
                response.Ephemeral("주문자가 없습니다.");
                return;
            }

            var sb = new StringBuilder();
            await sb.AppendOrderInfo(coffee, orders);

            response.Ephemeral(sb.ToString());
        }