コード例 #1
0
ファイル: RatingController.cs プロジェクト: rdarku/SpacePlace
        public IHttpActionResult Get([FromUri] RatingSearchParams spaceID)
        {
            var response = _service.GetAllRatings(spaceID);

            if (response == null)
            {
                return(NotFound());
            }
            return(Ok(response));
        }
コード例 #2
0
 public IEnumerable <RatingListItem> GetAllRatings(RatingSearchParams model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         return(ctx.Ratings
                .Where(r => r.SpaceId == model.SpaceId)
                .Select(r => new RatingListItem
         {
             SpaceId = r.SpaceId,
             Comments = r.Comments,
             CleanlinessRating = r.CleanlinessRating,
             EnvironmentRating = r.EnvironmentRating,
             ResponsivenessRating = r.ResponsivenessRating,
             LuxuryRating = r.LuxuryRating,
             AccessibilityRating = r.AccessibilityRating,
             RatingId = r.Id
         }
                        ).ToList());
     }
 }