Skip to content

Instantly share code, notes, and snippets.

@aidanmorgan
Created June 16, 2011 16:13
Show Gist options
  • Save aidanmorgan/1029603 to your computer and use it in GitHub Desktop.
Save aidanmorgan/1029603 to your computer and use it in GitHub Desktop.
public RatingDTO GetUserRatingForWhiskey(Guid userId, Guid whiskeyId)
{
using(IUnitOfWork uow = _unitOfWorkFactory.Create("RatingService.GetUserRatingForWhiskey"))
{
User u = uow.UserRepository.FindById(userId);
Whiskey w = uow.WhiskeyRepository.FindById(whiskeyId);
if(u == null)
{
throw new ArgumentException(string.Format("No User with id {0} exists.", userId));
}
if(w == null)
{
throw new ArgumentException(string.Format("No Whiskey with id {0} exists.", whiskeyId));
}
return (from r in u.Ratings where r.ReviewOf.Id == whiskeyId select RatingDTO.Create(r)).FirstOrDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment