public void updateConsumptionTable(Ingredient i)
        {
            var db  = new DatabaseAccess();
            var dbI = new DatabaseAccessIngredient();
            var dbConsumptionOuncesConsumed = new DatabaseAccessConsumptionOuncesConsumed();
            var convert      = new ConvertWeight();
            var dbD          = new DatabaseAccessDensities();
            var myIngredient = dbI.queryIngredientFromIngredientsTableByName(i);
            var myConsumptionTableIngredient = queryConsumptionTableRowByName(i);
            var myDensityTableIngredient     = dbD.queryIngredientFromDensityTableByName(i);
            //var myDensityTableIngredient = dbD.queryIngredientFromDensityTableByName(i);
            var temp = new Ingredient();

            //this handles egg classifications, calculates ounces consumed and ounces remaining
            if (myIngredient.classification.ToLower().Contains("egg"))
            {
                var currentOuncesConsumed = convert.EggsConsumedFromIngredientMeasurement(i.measurement);
                if (myConsumptionTableIngredient.ouncesConsumed != currentOuncesConsumed)
                {
                    i.ouncesConsumed = convert.EggsConsumedFromIngredientMeasurement(i.measurement);
                }
                if (myConsumptionTableIngredient.ouncesRemaining == 0m)
                {
                    i.ouncesRemaining = i.sellingWeightInOunces - i.ouncesConsumed;
                }
                else
                {
                    i.ouncesRemaining = myConsumptionTableIngredient.ouncesRemaining - i.ouncesConsumed;
                }
            }
            //this handles other ingredients; eggs have to be calculated by usage of egg, not by an actual measurement
            else
            {
                //if (i.ouncesConsumed == 0m)
                myConsumptionTableIngredient.ouncesConsumed = dbConsumptionOuncesConsumed.CalculateOuncesConsumedFromMeasurement(i);
                i.ouncesConsumed = myConsumptionTableIngredient.ouncesConsumed;
                if (myConsumptionTableIngredient.ouncesRemaining == 0m)
                {
                    myConsumptionTableIngredient.ouncesRemaining = myDensityTableIngredient.sellingWeightInOunces - myConsumptionTableIngredient.ouncesConsumed;
                }
                else
                {
                    myConsumptionTableIngredient.ouncesRemaining = myConsumptionTableIngredient.ouncesRemaining - myConsumptionTableIngredient.ouncesConsumed;
                }
                i.ouncesRemaining = myConsumptionTableIngredient.ouncesRemaining;
            }
            //if (string.IsNullOrEmpty(temp.name) && !(i.classification.ToLower().Contains("egg")))
            if (i.classification.ToLower().Contains("egg"))
            {
                temp.name = "Egg";
            }
            if (string.IsNullOrEmpty(temp.name))
            {
                temp.name = i.name;
            }
            //temp.name = i.name;
            //subtractOuncesRemainingIfExpirationDateIsPast(i);
            // this needs to be fixed, maybe for hte moment having a condition for ig it is eggs or dairy... flour and sugar, etc. should be totally fine
            var commandText = "update consumption set ounces_consumed=@ounces_consumed, ounces_remaining=@ounces_remaining, refill=@refill where name=@name;";

            db.executeVoidQuery(commandText, cmd => {
                cmd.Parameters.AddWithValue("@name", temp.name);
                cmd.Parameters.AddWithValue("@ounces_consumed", i.ouncesConsumed);
                cmd.Parameters.AddWithValue("@ounces_remaining", i.ouncesRemaining);
                cmd.Parameters.AddWithValue("@refill", i.restock);
                return(cmd);
            });
            doesIngredientNeedRestocking(i);
            //this is after the consumption insertion and update... so it should work fine...
            var myUpdatedIngredient = queryConsumptionTableRowByName(i);

            dbConsumptionOuncesConsumed.insertIngredientIntoConsumptionOuncesConsumed(i);
            //still not getting the ouncesRemaining... need to change this
            var consumptionOuncesConsumed = dbConsumptionOuncesConsumed.queryConsumptionOuncesConsumed();
            var myUpdatedIngredient2      = queryConsumptionTableRowByName(i);
            //why am i not inserting this into the database?
            var myUpdatedConsumptionOuncesConsumedTable = dbConsumptionOuncesConsumed.queryConsumptionOuncesConsumed();
        }
        public void UpdateIngredient(Ingredient i)
        {
            var db   = new DatabaseAccess();
            var rest = new MakeRESTCalls();

            if (i.sellingPrice == 0m)
            {
                myItemResponse = rest.GetItemResponse(i);
            }
            if (i.sellingPrice == 0m && (!i.classification.ToLower().Contains("dairy")) || (!i.classification.ToLower().Contains("egg")))
            {
                if (i.itemId == 0)
                {
                    myItemResponse = returnItemResponse(i);
                    i.itemId       = myItemResponse.itemId;
                }
                if (string.IsNullOrEmpty(i.itemResponseName))
                {
                    i.itemResponseName = myItemResponse.name;
                }
                if (i.sellingPrice == 0m)
                {
                    i.sellingPrice = myItemResponse.salePrice;
                }
            }
            if ((i.classification.ToLower().Contains("dairy")) || (i.classification.ToLower().Contains("egg")))
            {
                i.itemResponseName = " ";
                if (string.IsNullOrEmpty(i.classification))
                {
                    i.classification = " ";
                }
                if (i.expirationDate == null)
                {
                    i.expirationDate = new DateTime();
                }
            }
            if (i.priceOfMeasuredConsumption == 0)
            {
                i.priceOfMeasuredConsumption = MeasuredIngredientPrice(i);
            }
            if (string.IsNullOrEmpty(i.classification))
            {
                i.classification = " ";
            }
            var myIngredientId = i.ingredientId;
            var commandText    = @"update ingredients set name=@name, 
                                measurement=@measurement,
                                recipe_id=@recipeId, 
                                price_measured_ingredient=@price_measured_ingredient, 
                                item_id=@item_id, 
                                ingredient_type=@ingredient_type, 
                                ingredient_classification=@ingredient_classification, 
                                item_response_name=@item_response_name, 
                                expiration_date=@expiration_date 
                                where ing_id=@ing_id AND name=@name;";

            db.executeVoidQuery(commandText, cmd => {
                cmd.Parameters.AddWithValue("@name", i.name);
                cmd.Parameters.AddWithValue("@measurement", i.measurement);
                cmd.Parameters.AddWithValue("@recipeId", i.recipeId);
                cmd.Parameters.AddWithValue("@ingredientId", i.ingredientId);
                cmd.Parameters.AddWithValue("@price_measured_ingredient", i.priceOfMeasuredConsumption);
                cmd.Parameters.AddWithValue("@item_id", i.itemId);
                cmd.Parameters.AddWithValue("@ingredient_type", i.typeOfIngredient);
                cmd.Parameters.AddWithValue("@ing_id", i.ingredientId);
                cmd.Parameters.AddWithValue("@ingredient_classification", i.classification);
                cmd.Parameters.AddWithValue("@item_response_name", i.itemResponseName);
                cmd.Parameters.AddWithValue("@expiration_date", convertDateToStringMMDDYYYY(i.expirationDate));
                return(cmd);
            });
        }