Ejemplo n.º 1
0
        public string DoAction(string userAction)
        {
            int itemNumber;
            var answer = "Item added to the list";

            try
            {
                var searchString = actionsHelper.SplitQueryByAction(userAction, ActionString);

                var num = actionsHelper.SplitQueryByAction(searchString, "to");

                if (Int32.TryParse(num, out itemNumber))
                {
                    var itemToAdd = dataProvider.Data.Products.ElementAt(itemNumber - 1);
                    shoppingListManager.AddItem(itemToAdd);
                }
            }
            catch (Exception e)
            {
                answer = e.Message;
            }

            return(answer);
        }
Ejemplo n.º 2
0
        public string DoAction(string userAction)
        {
            var searchString = actionsHelper.SplitQueryByAction(userAction, ActionString);

            string answer;

            try
            {
                IResponseData <Product> data = (ShopYourWayApiResponseData)dataProvider.Fetch(searchString);

                answer = GetAnswerString(data);
            }
            catch (Exception e)
            {
                answer = "Something went wrong: " + e.Message;
            }

            return(answer);
        }