コード例 #1
0
        public List <ItemResponse> GetListItemResponses(Ingredient i)
        {
            var db                    = new DatabaseAccessRecipe();
            var convert               = new ConvertWeight();
            var items                 = MakeRequest <SearchResponse>(buildSearchRequest(i)).Items;
            var sellingWeightOunces   = convert.ConvertWeightToOunces(i.sellingWeight);
            var myListOfItemResponses = new List <ItemResponse>();

            foreach (var item in items)
            {
                if (!item.name.Contains('('))
                {
                    if ((!item.name.ToLower().Contains("pack of")) || (!item.name.ToLower().Contains(("pk"))))
                    {
                        if ((parseItemResponseName(item).Count() != 0) && (CompareWeightInOuncesFromItemResponseToIngredientSellingWeight(item, i) && (CompareItemResponseNameAndIngredientName(item, i))))
                        {
                            myListOfItemResponses.Add(item);
                        }
                    }
                }
            }
            return(myListOfItemResponses);
            //i would like to be able to return all brands that fit a certain selling weight, and give all of them as an option, and give the best price?
            //i think a good idea would be to have the item id associated with the ingredient in the ingredient database or the cost database, that way you can get the exact same item
        }
コード例 #2
0
        public void TestConvertImproperWeight()
        {
            var convert  = new ConvertWeight();
            var expected = 0m;
            var actual   = convert.ConvertWeightToOunces("5-6");

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void TestConvertWeightToOunces17()
        {
            var convert  = new ConvertWeight();
            var expected = .33m;
            var actual   = convert.ConvertWeightToOunces("1/3 ounces");

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void TestConvertWeightToOunces16()
        {
            var convert  = new ConvertWeight();
            var expected = 13.12m;
            var actual   = convert.ConvertWeightToOunces("13 1/8 ounces");

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void TestConvertWeightToOunces12()
        {
            var convert  = new ConvertWeight();
            var expected = 2.26m;
            var actual   = convert.ConvertWeightToOunces("64 grams");

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void TestConvertWeightToOunces11()
        {
            var convert  = new ConvertWeight();
            var expected = 1m;
            var actual   = convert.ConvertWeightToOunces("28.35 gram");

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
        public void TestConvertWeightToOunces10()
        {
            var convert  = new ConvertWeight();
            var expected = 377.60m;;
            var actual   = convert.ConvertWeightToOunces("2.95 gallons");

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
        public void TestConvertWeightToOunces9()
        {
            var convert  = new ConvertWeight();
            var expected = 128m;
            var actual   = convert.ConvertWeightToOunces("1 gallon");

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
        public void TestConvertWeightToOunces8()
        {
            var convert  = new ConvertWeight();
            var expected = 24m;
            var actual   = convert.ConvertWeightToOunces("3 cups");

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        public void TestConvertWeightToOunces6()
        {
            var convert  = new ConvertWeight();
            var expected = 58.67m;
            var actual   = convert.ConvertWeightToOunces("3 2/3 pint");

            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
        public void TestConvertWeightToOunces5()
        {
            var convert  = new ConvertWeight();
            var expected = 16m;
            var actual   = convert.ConvertWeightToOunces("1 lb");

            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void TestConvertWeightToOunces4()
        {
            var convert  = new ConvertWeight();
            var expected = 108m;
            var actual   = convert.ConvertWeightToOunces("6.75 pint");

            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
        public void TestConvertWeightToOunces2()
        {
            var convert  = new ConvertWeight();
            var expected = 32m;
            var actual   = convert.ConvertWeightToOunces("1/4 gallon milk");

            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
        public bool CompareWeightInOuncesFromItemResponseToIngredientSellingWeight(ItemResponse response, Ingredient i)
        {
            var convert             = new ConvertWeight();
            var productNameArray    = parseItemResponseName(response);
            var productWeight       = productNameArray[1];
            var productWeightOunces = convert.ConvertWeightToOunces(productWeight);

            //this product weight in ounces is incorrect...
            if (convert.ConvertWeightToOunces(i.sellingWeight) == productWeightOunces)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #15
0
        public ItemResponse GetItemResponse(Ingredient i)
        {
            var db               = new DatabaseAccessRecipe();
            var convert          = new ConvertWeight();
            var newItemResponse  = new ItemResponse();
            var tempItemResponse = new ItemResponse();

            try {
                if (string.IsNullOrEmpty(i.classification) || (i.classification == " ") || !(i.classification.ToLower().Contains("dairy")) || !(i.classification.ToLower().Contains("egg")))
                {
                    if ((MakeRequest <SearchResponse>(buildSearchRequest(i)).Items.Count() == 0))
                    {
                        return(newItemResponse);//ok, selling weight is not being transfered
                    }
                    var items = MakeRequest <SearchResponse>(buildSearchRequest(i)).Items;
                    var sellingWeightOunces = convert.ConvertWeightToOunces(i.sellingWeight);
                    foreach (var item in items)
                    {
                        if (!item.name.Contains('('))
                        {
                            if ((!item.name.ToLower().Contains("pack of")) || (!item.name.ToLower().Contains(("pk"))))
                            {
                                if ((parseItemResponseName(item).Count() != 0) && (CompareWeightInOuncesFromItemResponseToIngredientSellingWeight(item, i) && (CompareItemResponseNameAndIngredientName(item, i))))
                                {
                                    tempItemResponse = item;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if ((i.classification.ToLower().Contains("dairy")) || i.classification.ToLower().Contains("eggs"))
                    {
                        return(newItemResponse);
                    }
                }
            } catch {
                return(newItemResponse);
            }
            return(tempItemResponse);
            //i would like to be able to return all brands that fit a certain selling weight, and give all of them as an option, and give the best price?
        }