/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (PrepTime != null) { hashCode = hashCode * 59 + PrepTime.GetHashCode(); } if (TotalTime != null) { hashCode = hashCode * 59 + TotalTime.GetHashCode(); } if (Servings != null) { hashCode = hashCode * 59 + Servings.GetHashCode(); } if (ServingSize != null) { hashCode = hashCode * 59 + ServingSize.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if RecipeObjectAttributes instances are equal /// </summary> /// <param name="other">Instance of RecipeObjectAttributes to be compared</param> /// <returns>Boolean</returns> public bool Equals(RecipeObjectAttributes other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( PrepTime == other.PrepTime || PrepTime != null && PrepTime.Equals(other.PrepTime) ) && ( TotalTime == other.TotalTime || TotalTime != null && TotalTime.Equals(other.TotalTime) ) && ( Servings == other.Servings || Servings != null && Servings.Equals(other.Servings) ) && ( ServingSize == other.ServingSize || ServingSize != null && ServingSize.Equals(other.ServingSize) )); }
public ProductDto(Product product, ProductVersion productVersion) { Id = product.Id; BarCode = product.BarCode; Complete = true; Name = productVersion.Name; VersionId = productVersion.Id; foreach (var serving in productVersion.ProductServings) { Servings.Add(new ProductServingDto { Carbohydrates = serving.Carbohydrates, Calories = serving.Calories, Fats = serving.Fats, Id = serving.Id, Protein = serving.Protein, ProductVersionId = productVersion.Id, ServingSize = serving.ServingSize, ServingSizeUnit = serving.ServingSizeUnit }); } }