/// <summary> /// need to decide how to handle the /// </summary> /// <param name="upd"></param> private void UpdateIngredientXref(UpdateObject upd) { var linkedingredients = new MenuItemIngredient(); linkedingredients.menuitemingredientid = upd.xrefpk; linkedingredients.menuitemid = upd.menuid; linkedingredients.ingredientid = upd.ingredientid; linkedingredients.sortindex = upd.sortindex; linkedingredients.ServiceObjectId = upd.ServiceObjectId ?? new Guid(); linkedingredients.DataObjectId = upd.DataObjectId ?? new Guid(); linkedingredients.Insert(); }
private void UpdateIngredientNutritionalInformation(UpdateObject update, ref UpdateResults results) { // need to get the xmlimportitem var xmlimport = GetXmlIngredientByGuid(update.xmlingredientguid.ToString()); if ( xmlimport == null) throw new ApplicationException("XmlImportIngredient not found"); //need to blow out the previous facts GetDataBase().Execute(" update NutritionFacts set active = 0 where ingredientid =@0", update.ingredientid); //translate field to nutrition type foreach (var facttype in GetDataBase().Fetch<NutritionFactType>(" select * from NutritionFactTypes")) { try { var fact = GetNutritionFact(update.ingredientid, facttype.nutritionfacttypeid); if (fact == null) { fact = new NutritionFact(); fact.ingredientid = update.ingredientid; fact.nutritionfacttypeid = facttype.nutritionfacttypeid; fact.ServiceObjectId = new Guid(); fact.DataObjectId = new Guid(); } fact.active = true; fact.value = GetFactValueFromImport(xmlimport, facttype.nutritionfacttypeid); if (fact.IsNew()) fact.Insert(); else fact.Update(); results.NutrionalFactsUpdates++; } catch (Exception e) { results.Errors.Add("NutrionalFact:" + facttype.name + " for Ingredient:" + update.ingredientid, e.Message); } } }