public ActionResult Rate(int beerId, double score) { if (User.Identity.IsAuthenticated) { var userID = Convert.ToInt32((Membership.GetUser(User.Identity.Name)).ProviderUserKey); var ratings = new RatingFacade(); var success = ratings.Rate(beerId, score*2, userID); return Json(success); } return new HttpNotFoundResult(); }
public BeerViewModel Get(int id) { var beer = _beerFacade.Get(id); if(beer == null) throw new HttpResponseException(HttpStatusCode.NotFound); var ratings = new RatingFacade(); var rating = ratings.Get(id, WebSecurity.CurrentUserId); if (rating != null) { beer.Overall = rating.Overall; } else { beer.Overall = 0; } return beer; }