public bool isValid() { UnitKey key = new UnitKey(); key.fromUnit = fromUnit; key.toUnit = toUnit; Calculator calc = new Calculator(); if (calc.unitDictionary.ContainsKey(key)) { return(true); } else { return(false); } }
private static SqlDataRecord CreateBookRecipeIngredientRecord(EditIngredientModel ingredient) { var dataRecord = new SqlDataRecord(BookRecipeIngredientMetaData); dataRecord.SetInt32(0, ingredient.IngredientNo.Value); dataRecord.SetString(1, ingredient.Name); dataRecord.SetDecimal(2, ingredient.Quantity.Value); var quantityUnit = UnitKey.Parse(ingredient.QuantityUnit); dataRecord.SetString(3, quantityUnit.UnitTypeCode); dataRecord.SetString(4, quantityUnit.UnitCode); dataRecord.SetDecimal(5, ingredient.Serving.Value); var servingUnit = UnitKey.Parse(ingredient.ServingUnit); dataRecord.SetString(6, servingUnit.UnitTypeCode); dataRecord.SetString(7, servingUnit.UnitCode); dataRecord.SetDecimal(8, ingredient.CaloriesPerServing.Value); dataRecord.SetDecimal(9, ingredient.ProteinPerServing.Value); return(dataRecord); }
public override int GetHashCode() { return(UnitKey.GetHashCode()); }