Exemplo n.º 1
0
        public async Task <IActionResult> Do()
        {
            using var coffee = new CoffeeService(_coffeeContext);

            string id   = Request.Form["userId"];
            string name = Request.Form["userName"];

            var user = await coffee.FindUserAsync(id);

            if (user == null)
            {
                user = await coffee.CreateUserAsync(id, false);
            }

            var splitted = Request.Form["text"].ToString().Trim().Split(' ', 2);

            var command = splitted[0];
            var option  = splitted.Length > 1 ? splitted[1] : "";

            var handler = handlers.GetHandler(this, user, command);

            if (handler == null)
            {
                return(SlackBadRequest("없는 명령어 입니다."));
            }

            try
            {
                return(await handler(option));
            }
            catch (BadRequestException e)
            {
                return(SlackBadRequest(e.Message));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Handle(TestUser user, string command)
        {
            var handler = handlers.GetHandler(this, user, command);

            if (handler == null)
            {
                return(new BadRequestResult());
            }
            return(await handler(""));
        }