Created
June 22, 2011 12:15
-
-
Save aidanmorgan/1039956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WhiskeyDTO | |
{ | |
public static WhiskeyDTO Create(Whiskey w) | |
{ | |
WhiskeyDTO dto = new WhiskeyDTO(); | |
dto.Name = w.Name; | |
dto.Id = w.Id; | |
dto.Description = w.Description; | |
dto.Type = WhiskeyTypeDTO.Create(w.Type); | |
if(w.Distillery != null) | |
{ | |
dto.Distillery = w.Distillery.Id; | |
} | |
foreach(Rating r in w.Ratings) | |
{ | |
dto.Ratings.Add(r.Id); | |
} | |
if(w.Ratings.Count > 0) | |
{ | |
dto.AverageScore = w.AverageRating; | |
} | |
dto.Score = w.TotalRating; | |
return dto; | |
} | |
public double Score { get; private set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
public Guid Id { get; set; } | |
public Guid Distillery { get; set; } | |
public IList<Guid> Ratings { get; set; } | |
public WhiskeyTypeDTO Type { get; set; } | |
public double? AverageScore { get; set; } | |
private WhiskeyDTO() | |
{ | |
Ratings = new List<Guid>(); | |
} | |
public void Update(Whiskey whiskey) | |
{ | |
whiskey.Name = Name; | |
whiskey.Description = Description; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment