コード例 #1
0
        private async Task<HttpResponseMessage> Rate(RatingRequest ratingRequest, bool isPositive)
        {
            var authUser = GetThisAuthenticatedUser();
            if (authUser == null)
            {
                return Request.CreateResponse(HttpStatusCode.Unauthorized);
            }

            var theDeal =
                await
                    db.GetSpecificDeal(ratingRequest.StoreName, ratingRequest.ProductName, ratingRequest.ExpirationDate,
                        ratingRequest.Price);

            if (theDeal == null)
                return new HttpResponseMessage(HttpStatusCode.NotFound);

            await db.RateDeal(theDeal, authUser, isPositive);
            return new HttpResponseMessage(HttpStatusCode.OK);
        }
コード例 #2
0
 public async Task<HttpResponseMessage> PostDislike(RatingRequest ratingRequest)
 {
     return await Rate(ratingRequest, false);
 }
コード例 #3
0
 public async Task<HttpResponseMessage> PostLike(RatingRequest ratingRequest)
 {
     return await Rate(ratingRequest, true);
 }