Exemple #1
0
        public async Task <ActionResult> Index()
        {
            ViewBag.BaseApiUrl = ConfigurationManager.AppSettings["BaseApiUrl"];

            var benches = await repository.GetList();

            return(View(benches));
        }
        public async Task <IHttpActionResult> Get()
        {
            var benches = await repository.GetList();

            var flattendBenches = benches.Select(b => new
            {
                BenchId         = b.Id,
                Description     = b.ShortDescription,
                NumberOfSeats   = b.NumberOfSeats,
                Latitude        = b.Latitude,
                Longitude       = b.Longitude,
                HasReviews      = b.Reviews.Count > 0,
                AverageRating   = b.AverageRating,
                UserDisplayName = b.User.DisplayName
            }).ToList();

            return(Ok(flattendBenches));
        }