public WineFactory(WineType typeOfWine)
        {
            switch (typeOfWine)
            {
            case WineType.Bordeaux:
                _wine = new Bordeaux();
                break;

            case WineType.Rioja:
                _wine = new Rioja();
                break;

            case WineType.Porto:
                _wine = new Porto();
                break;

            default:
                _wine = new Bordeaux();
                break;
            }
        }
 public WineItemsProvider(IWine repository)
 {
     _repository = repository;
 }
Exemple #3
0
        public SkillResponse GetWine(SkillRequest input, ILambdaContext context)
        {
            try
            {
                var requestType = input.GetRequestType();
                if (requestType == typeof(IntentRequest))
                {
                    IFood request   = null;
                    var   intentReq = input.Request as IntentRequest;
                    if (intentReq.Intent.Name == "AMAZON.HelpIntent" || intentReq.Intent.Slots.ContainsKey("meat") == false)
                    {
                        return(ResponseBuilder.Ask("Try asking for a meat to pair.", new Reprompt("Would you like to pair a meat?")));
                    }


                    string intentValue = intentReq.Intent.Slots["meat"].Value;
                    if (intentValue.Contains("beef") ||
                        intentValue.Contains("steak") ||
                        intentValue.Contains("lamb") ||
                        intentValue.Contains("goat") ||
                        intentValue.Contains("veal"))
                    {
                        request = new RedMeat();
                    }
                    else if (intentValue.Contains("cured") ||
                             intentValue.Contains("bacon") ||
                             intentValue.Contains("salami"))
                    {
                        request = new CuredMeat();
                    }
                    else if (intentValue.Contains("pork") ||
                             intentValue.Contains("ham"))
                    {
                        request = new Pork();
                    }
                    else if (intentValue.Contains("chicken") ||
                             intentValue.Contains("poultry") ||
                             intentValue.Contains("light meat") ||
                             intentValue.Contains("dark meat") ||
                             intentValue.Contains("duck") ||
                             intentValue.Contains("turkey") ||
                             intentValue.Contains("goose"))
                    {
                        request = new Poultry();
                    }
                    else if (intentValue.Contains("mollusk") ||
                             intentValue.Contains("clam") ||
                             intentValue.Contains("oyster") ||
                             intentValue.Contains("mussel") ||
                             intentValue.Contains("scallop"))
                    {
                        request = new Mollusk();
                    }
                    else if (intentValue.Contains("shellfish") ||
                             intentValue.Contains("shrimp") ||
                             intentValue.Contains("lobster") ||
                             intentValue.Contains("crab"))
                    {
                        request = new Shellfish();
                    }
                    else if (intentValue.Contains("fish") ||
                             intentValue.Contains("seafood") ||
                             intentValue.Contains("salmon"))
                    {
                        request = new Fish();
                    }


                    if (request == null)
                    {
                        Console.WriteLine("Null request sent to matching service with intentValue: " + intentValue);
                    }

                    var   matches = _winePair.FindBestMatchingWines(request);
                    IWine match1, match2 = match1 = null;
                    if (matches.Count >= 2)
                    {
                        match1 = matches[0];
                        match2 = matches[1];
                    }
                    else if (matches.Count == 1)
                    {
                        match1 = matches[0];
                    }

                    if (match1 == null && match2 == null)
                    {
                        throw new Exception("Could not find matching wine.");
                    }



                    string response;
                    if (match1 != null && match2 != null)
                    {
                        response = string.Format("You should try a {0} wine like {1} or a {2} wine like {3}", match1.Style.ToString(), match1.Name, match2.Style.ToString(), match2.Name);
                    }
                    else
                    {
                        response = string.Format("You should try a {0} wine like {1}", match1.Style.ToString(), match1.Name);
                    }

                    return(ResponseBuilder.Tell(response));
                }
                else if (requestType == typeof(LaunchRequest))
                {
                    var response = ResponseBuilder.Ask("What can I pair for you?", new Reprompt("Would you like to pair a wine?"));
                    response.Response.ShouldEndSession = false;
                    return(response);
                }
            }
            catch (Exception e)
            {
                Console.Write("Exception Caught: ");
                Console.WriteLine(e);
            }

            return(ResponseBuilder.Ask("What would you like to pair?", new Reprompt("What would you like to pair?")));
        }
 public WineController(IWine repository)
 {
     _repository       = repository;
     wineItemsProvider = new WineItemsProvider(_repository);
 }