Example #1
0
        public string ResponseToMultipleKeyWords()
        {
            string result = "";

            if (ResponseHolder.ToLower().Contains("motivation") || ResponseHolder.ToLower().Contains("quote") || ResponseHolder.ToLower().Contains("tired"))
            {
                result = GetMotivation();
            }
            else if (ResponseHolder.ToLower().Contains("calendar") || ResponseHolder.ToLower().Contains("events"))
            {
                result       = GetCalendarEvents();
                HoldOverItem = new DatabaseItem();
            }
            else if (ResponseHolder.ToLower().Contains("job") || ResponseHolder.ToLower().Contains("position") || ResponseHolder.ToLower().Contains("opening"))
            {
                result = GetAllJobListings();
            }
            else
            {
                List <DatabaseItem> keywordList = new List <DatabaseItem>();
                foreach (KeyValuePair <string, string> item in FoundKeyWords)
                {
                    if (item.Key != "")
                    {
                        DatabaseItem keyItem = GetItemList(item.Key, item.Value);
                        keywordList.Add(keyItem);

                        //result = keyItem.Description;
                        //if (keyItem.CategoryDescription != null && keyItem.CategoryName != null)
                        //{
                        //    result += " . \nThe information you requested was under the category " + keyItem.CategoryName + ". " + keyItem.CategoryDescription;
                        //}
                    }
                }

                keywordList = (keywordList.OrderBy(x => x.Weight)).ToList();

                List <DatabaseItem> positionList = keywordList.FindAll(x => x.CategoryName == "positions");
                if (positionList.Count > 0)
                {
                    foreach (DatabaseItem item in positionList)
                    {
                        result += item.Name + "\n\n" + item.Website + "\n\n";
                    }
                }
                else if (keywordList[keywordList.Count - 1].Weight - keywordList[keywordList.Count - 2].Weight >= 5)
                {
                    result       = keywordList[keywordList.Count - 1].Description + "<a target = '_blank' href = " + keywordList[keywordList.Count - 1].Website + ">" + keywordList[keywordList.Count - 1].Website + "</a>";
                    result      += " . \n\nThe information you requested was under the category " + keywordList[keywordList.Count - 1].CategoryName + ". " + keywordList[keywordList.Count - 1].CategoryDescription;
                    result      += "\n\n" + "Is this what you were looking for (please click yes or no)?";
                    HoldOverItem = keywordList[keywordList.Count - 1];
                    HoldOverList = keywordList;
                }
                else
                {
                    HoldOverItem = new DatabaseItem();
                    result       = "What do you want to learn more about? \n";
                    foreach (DatabaseItem item in keywordList)
                    {
                        result += item.Name + "\n";
                    }

                    //result = result.Substring(0, result.Length - 2);
                }
            }

            return(result);
        }
Example #2
0
        public string ResponseToOneKeyWord()
        {
            string result = "";


            if (ResponseHolder.ToLower().Contains("motivation") || ResponseHolder.ToLower().Contains("quote") || ResponseHolder.ToLower().Contains("tired"))
            {
                result       = GetMotivation();
                HoldOverItem = new DatabaseItem();
            }
            else if (ResponseHolder.ToLower().Contains("calendar") || ResponseHolder.ToLower().Contains("events"))
            {
                result       = GetCalendarEvents();
                HoldOverItem = new DatabaseItem();
            }
            else if (ResponseHolder.ToLower().Contains("job") || ResponseHolder.ToLower().Contains("position") || ResponseHolder.ToLower().Contains("opening"))
            {
                result       = GetAllJobListings();
                HoldOverItem = new DatabaseItem();
            }
            else if (ResponseHolder.ToLower() == "no" && HoldOverItem.Name != null)
            {
                HoldOverItem.Weight--;
                UpdateWeight(HoldOverItem);
                HoldOverItem = new DatabaseItem();
                result       = "What did you want to learn more about? " + "\n";
                foreach (DatabaseItem item in HoldOverList)
                {
                    result += item.Name + "\n";
                }

                HoldOverList = new List <DatabaseItem>();
            }
            else if (ResponseHolder.ToLower() == "yes" && HoldOverItem.Name != null)
            {
                HoldOverList = new List <DatabaseItem>();
                HoldOverItem = new DatabaseItem();
                result       = "Thank you";
            }
            else
            {
                HoldOverItem = new DatabaseItem();
                foreach (KeyValuePair <string, string> item in FoundKeyWords)
                {
                    if (item.Key != "")
                    {
                        DatabaseItem keyItem = GetItemList(item.Key, item.Value);

                        if (keyItem.Website == null)
                        {
                            keyItem.Website = "";
                        }

                        if (keyItem.Website.Contains("|"))
                        {
                            string[] websiteList = keyItem.Website.Split("|");
                            for (int i = 0; i < websiteList.Length; i++)
                            {
                                websiteList[i] = "<a target = '_blank' href = " + websiteList[i] + ">" + websiteList[i] + "</a>";
                            }
                            result = string.Join("\n", websiteList);
                        }
                        else
                        {
                            result = keyItem.Description + "\n" + "<a target = '_blank' href = " + keyItem.Website + ">" + keyItem.Website + "</a>";
                        }


                        if (keyItem.CategoryDescription != null && keyItem.CategoryName != null)
                        {
                            result += " \n\nThe information you requested was under the category " + keyItem.CategoryName + ": " + keyItem.CategoryDescription;
                            int updatedWeight = keyItem.Weight++;
                            UpdateWeight(keyItem);
                        }
                    }
                }
            }


            return(result);
        }