Ejemplo n.º 1
0
        public List <string> AutoComplete(string lookUpWord)
        {
            using (var db = new Database.Context())
            {
                var productList = db.FindProductStartingWith(lookUpWord);

                if (productList == null)
                {
                    return(null);          //Produktet findes ikke i databasen
                }
                List <string> AutoCopmpleteList = new List <string>();
                for (int i = 0; i < productList.Count; i++)
                {
                    AutoCopmpleteList.Add(productList[i].ProductName);
                    if (i == 2)
                    {
                        break;
                    }
                }

                return(AutoCopmpleteList);
            }
        }
Ejemplo n.º 2
0
        public Store FindCheapestStore(string productName)
        {
            using (var db = new Database.Context())
            {
                var product = db.FindProduct(productName);

                if (product == null)
                {
                    return(null);          //Produktet findes ikke i databasen
                }
                var cheapest = product.StoreProducts.First();

                foreach (var storprod in product.StoreProducts)
                {
                    if (storprod.Price < cheapest.Price)
                    {
                        cheapest = storprod;
                    }
                }

                return(cheapest.Store);
            }
        }