コード例 #1
0
        //uses LUIS to understand user query inteligently, and respond appropriately
        private async Task <Activity> NaturalInteractionHandler(Activity message)
        {
            if ((message.Text.Trim().ToLower() ?? "") == "")
            {
                return(message.CreateReply("Error: Message type unsupported"));
            }
            LUISHandler.LUISQueryResult LUISResult = await LUISHandler.HandleQuery(message.Text);

            switch (LUISResult.responseType)
            {
            case LUISHandler.ResponseType.ExchangeRate:
                return(await ExchangeRateHandler.HandleExchangeRateMessage(message, LUISResult));

            case LUISHandler.ResponseType.Logout:
                return(await FacebookHandler.LogoutHandler(message));

            case LUISHandler.ResponseType.None:
                return(await UnknownHandler(message));

            case LUISHandler.ResponseType.AccountBalance:
                return(await BankHandler.HandleBalance(message));

            case LUISHandler.ResponseType.MakePayment:
                return(await BankHandler.HandleTransaction(message, LUISResult));

            case LUISHandler.ResponseType.TransactionHistory:
                return(await BankHandler.HandleHistory(message));

            default:
                return(message.CreateReply("Error: Unimplemented"));
            }
        }
コード例 #2
0
        public JsonResult GetExchangeRateByTargetDate()
        {
            ExchangeRateHandler handler = new ExchangeRateHandler();
            string   baseDateStr        = Request.Form["targetDate"];
            DateTime?targetDate         = DateTime.ParseExact(baseDateStr, "d/MMM/yyyy", null);

            return(Json(handler.GetExchangeRateByTargetDate(targetDate)));
        }
コード例 #3
0
        public ActionResult Index(object o)
        {
            string firstCurrency  = Request.Form["first-currency"];
            string secondCurrency = Request.Form["second-currency"];

            ExchangeRateHandler pbh = new ExchangeRateHandler();
            var list = new List <Currency>();

            list = pbh.getCalculateExchangeRates(int.Parse(firstCurrency), int.Parse(secondCurrency));
            return(View("Results", list));
        }
コード例 #4
0
        public void ExchangeRateHandler_SetNewRequest_CountryIsNotSpecified(
            string inputMessage, string expectedCurrency, string expectedCountry,
            int expectedYear, int expectedMonth, int expectedDay)
        {
            // Arrange
            var availableObservers  = new List <IExchangeRateHandlerObserver>();
            var exchangeRateHandler = new ExchangeRateHandler(availableObservers);

            // Act
            exchangeRateHandler.SetNewRequest(inputMessage);

            var actualCurrency = exchangeRateHandler.Request.Currency;
            var actualCountry  = exchangeRateHandler.Request.Country;
            var actualYear     = exchangeRateHandler.Request.Date.Year;
            var actualMonth    = exchangeRateHandler.Request.Date.Month;
            var actualDay      = exchangeRateHandler.Request.Date.Day;

            // Assert
            Assert.AreEqual(actualCurrency, expectedCurrency);
            Assert.AreEqual(actualCountry, expectedCountry);
            Assert.AreEqual(actualYear, expectedYear);
            Assert.AreEqual(actualMonth, expectedMonth);
            Assert.AreEqual(actualDay, expectedDay);
        }
コード例 #5
0
        public JsonResult GetCurrentExchangeRate()
        {
            ExchangeRateHandler handler = new ExchangeRateHandler();

            return(Json(handler.GetCurrentExchangeRate(DateTime.Now.Date)));
        }
コード例 #6
0
        public ActionResult RegisterRate()
        {
            ExchangeRateHandler handler = new ExchangeRateHandler();

            return(Json(handler.RegisterRate(Request.Form)));
        }
コード例 #7
0
        public ActionResult GetCalendarItems(string start, string end)
        {
            ExchangeRateHandler handler = new ExchangeRateHandler();

            return(Json(handler.GetAllExchangeRateForCalendar()));
        }