Created
June 16, 2011 16:18
-
-
Save aidanmorgan/1029607 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 RatingDTO Create(Guid userId, Guid whiskeyId, int score, string review = "") | |
{ | |
using(IUnitOfWork uow = _unitOfWorkFactory.Create("RatingService.Create")) | |
{ | |
Rating r = uow.RatingRepository.All().Where(x => x.ReviewOf.Id == whiskeyId && x.ReviewedBy.Id == userId).FirstOrDefault(); | |
Whiskey w = uow.WhiskeyRepository.FindById(whiskeyId); | |
User u = uow.UserRepository.FindById(userId); | |
// there is no existing Rating in the system, so create a new one.)) | |
if(r == null) | |
{ | |
r = uow.RatingRepository.Create(w, u, score); | |
} | |
r.Review = review; | |
UpdateScores(w); | |
uow.Save(); | |
return RatingDTO.Create(r); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment