Пример #1
0
        private async Task <string> takeAction(string text)
        {
            var result      = string.Empty;
            var luisService = new LuisService();
            var resultado   = await luisService.MakeRequest(text);

            // encender

            if (resultado == "encendercocina")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOnKitchenAction);

                return("Luz de la cocina encendida");
            }

            if (resultado == "encenderbaño")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOnBathRoomAction);

                return("Luz del baño encendida");
            }

            if (resultado == "encenderrecibidor")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOnEntranceHallAction);

                return("Luz del recibidor encendida");
            }

            if (resultado == "encenderhabitacion")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOnBedroomAction);

                return("Luz de la habitación encendida");
            }

            //apagar

            if (resultado == "apagarcocina")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOffKitchenAction);

                return("Luz de la cocina apagada");
            }

            if (resultado == "apagarbaño")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOffBathRoomAction);

                return("Luz del baño apagada");
            }

            if (resultado == "apagarrecibidor")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOffEntranceHallAction);

                return("Luz del recibidor apagada");
            }

            if (resultado == "apagarhabitacion")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOffBedroomAction);

                return("Luz de la habitación apagada");
            }

            if (resultado == "apagartodo")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOffAllAction);

                return("Apagadas todas las luces de la casa");
            }

            // bajar persiana

            if (resultado == "bajarpersianacocina")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.blindDownKitchenAction);

                return("Bajada la persiana de la cocina");
            }

            if (resultado == "bajarpersianahabitacion")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.blindDownBedroomAction);

                return("Bajada la persiana de la habitación");
            }

            if (resultado == "bajarpersianabuzon")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.blindDownMailboxAction);

                return("Bajada la persiana del buzón");
            }


            // subir persiana

            if (resultado == "subirpersianacocina")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.blindUpKitchenAction);

                return("Subida la persiana de la cocina");
            }

            if (resultado == "subirpersianahabitacion")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.blindUpBedroomAction);

                return("Subida la persiana de la habitación");
            }

            if (resultado == "subirpersianabuzon")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.blindDownMailboxAction);

                return("Subida la persiana del buzón");
            }

            if (resultado == "carteropaquete")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.mailUserRequestAction);

                return("Por favor deposita el paquete en el buzón");
            }

            if (resultado == "encendertodo")
            {
                HomeRestService homeRestService = new HomeRestService();
                await homeRestService.ExecuteAction(HomeRestService.lightOnAllAction);

                return("Encendidas todas las luces de la casa");
            }


            return(resultado);
        }