Example #1
0
        private List <AIBot_FYP16004.Models.DeviceCatalog> searchDB(DeviceOrder2 order)
        {
            Models.CustomerBotDBEntities1 DB = new Models.CustomerBotDBEntities1();
            var products    = (from DeviceCatalog in DB.DeviceCatalogs select DeviceCatalog).ToList();
            var brand       = order.Brand_value.ToString();
            var category    = order.type_value.ToString();
            var price_range = order.price_range.ToString();

            if (brand != "Unknown")
            {
                products = (from product in products where product.Manufacturer.Contains(brand) select product).ToList();
            }
            if (category != "Unknown")
            {
                if (category == "twoInOne")
                {
                    products = (from product in products where product.FormFactor.Contains("2-in-1") select product).ToList();
                }
                else if (category == "Desktop")
                {
                    products = (from product in products where product.FormFactor.Contains("Desktop") select product).ToList();
                }
                else if (category == "GamingDevices")
                {
                    products = (from product in products where product.FormFactor.Contains("Gaming Device") select product).ToList();
                }
                else if (category == "Notebook")
                {
                    products = (from product in products where product.FormFactor.Contains("Notebook") select product).ToList();
                }
                else if (category == "Tablet")
                {
                    products = (from product in products where product.FormFactor.Contains("2-in-1 Detachable") select product).ToList();
                }
            }
            if (price_range == "Range1")
            {
                products = (from product in products where product.PriceUSD * 7.8 >= 5000 && product.PriceUSD * 7.8 <= 8000 select product).ToList();
            }
            else if (price_range == "Range2")
            {
                products = (from product in products where product.PriceUSD * 7.8 >= 8000 && product.PriceUSD * 7.8 <= 12000 select product).ToList();
            }
            else if (price_range == "Range3")
            {
                products = (from product in products where product.PriceUSD * 7.8 >= 12000 && product.PriceUSD * 7.8 <= 15000 select product).ToList();
            }
            else if (price_range == "Range4")
            {
                products = (from product in products where product.PriceUSD * 7.8 >= 15000 select product).ToList();
            }
            return(products);
        }
Example #2
0
        private void handle_complaint(IActivity activity, string product, string service, string query)
        {
            Models.CustomerBotDBEntities1 DB = new Models.CustomerBotDBEntities1();
            Models.Complaint newComplaint    = new Models.Complaint();
            newComplaint.Channel  = activity.ChannelId;
            newComplaint.UserID   = activity.From.Id;
            newComplaint.UserName = activity.From.Name;
            newComplaint.Time     = DateTime.Now;
            newComplaint.Content  = query;
            string type = "General";

            if (product != "")
            {
                type = "Product";
            }
            else if (service != "")
            {
                type = "Service";
            }
            newComplaint.Type = type;
            DB.Complaints.Add(newComplaint);
            DB.SaveChanges();
        }
Example #3
0
        private List <AIBot_FYP16004.Models.DeviceCatalog> get_recommendation(string category)
        {
            Models.CustomerBotDBEntities1 DB = new Models.CustomerBotDBEntities1();
            var products = (from DeviceCatalog in DB.DeviceCatalogs select DeviceCatalog).ToList();
            //List<AIBot_FYP16004.Models.DeviceCatalog> results = null;
            var    results = products;
            Random rnd     = new Random();

            if (category == "2in1")
            {
                products = (from product in products where product.FormFactor.Contains("2-in-1") select product).ToList();
            }
            else if (category == "Desktop")
            {
                products = (from product in products where product.FormFactor.Contains("Desktop") select product).ToList();
            }
            else if (category == "Notebook")
            {
                products = (from product in products where product.FormFactor.Contains("Notebook") select product).ToList();
            }
            else if (category == "Tablet")
            {
                products = (from product in products where product.FormFactor.Contains("2-in-1 Detachable") select product).ToList();
            }
            else if (category == "GamingDevices")
            {
                results  = (from product in products select product).OrderByDescending(x => x.PriceUSD).Take(4).ToList();
                products = (from product in products where product.FormFactor.Contains("Gaming Device") select product).ToList();
                products.AddRange(results);
                return(products);
            }
            var brands = products.Select(p => p.Manufacturer).Distinct().ToList();

            for (int i = 0; i < 5; i++)
            {
                var candidates = (from product in products where product.Manufacturer.Contains(brands[i]) select product).ToList();
                int index      = rnd.Next(0, candidates.Count);
                if (i == 0)
                {
                    if (index > 0)
                    {
                        results = candidates.Skip(index).Take(1).ToList();
                    }
                    else
                    {
                        results = candidates.Take(1).ToList();
                    }
                }
                else
                {
                    if (index > 0)
                    {
                        results.AddRange(candidates.Skip(index).Take(1));
                    }
                    else
                    {
                        results.AddRange(candidates.Take(1));
                    }
                }
            }
            return(results);
        }