Esempio n. 1
0
 public static RatingListModel getLatestRatings()
 {
     var ratingList = new RatingListModel();
     using (var db = new shamethethronesContext())
     {
         var ratings = db.Ratings.Take(50).OrderByDescending(e => e.id).ToList();
         foreach(var rating in ratings)
         {
             var ratingModel = new RatingModel(rating);
             ratingList.add(ratingModel);
         }
     }
     return ratingList;
 }
Esempio n. 2
0
        public RestroomWithRatingModel getRestroomWithRating(int restroomId)
        {
            using (var db = new shamethethronesContext())
            {
                Restroom restroomModel = db.Restrooms.Single(x => x.id == restroomId);
                var ratings = db.Ratings.Where(x => x.restroomId == restroomId).OrderByDescending(x => x.id).Take(50).ToList();


                var restroom = new RestroomModel(restroomModel);

                var ratingsListModel = new RatingListModel(ratings);
                
                var restroomWithRating = new RestroomWithRatingModel();
                restroomWithRating.restroomModel = restroom;
                restroomWithRating.ratingModels = ratingsListModel;

                return restroomWithRating;
            } 
        }