public HttpResponseMessage GetAll()
        {
            var accommodationAds = context.AccommodationAds
                                   .OrderByDescending(x => x.PublishedDate)
                                   .Select(a => a)
                                   .ToList <AccommodationAd>();

            if (accommodationAds == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            ICollection <AccommodationBindingModel> result = new List <AccommodationBindingModel>();
            AccommodationBindingModel model = null;

            foreach (AccommodationAd accommodationAd in accommodationAds)
            {
                model                = new AccommodationBindingModel();
                model.Id             = accommodationAd.Id;
                model.Author         = accommodationAd.Author;
                model.Title          = accommodationAd.Title;
                model.Content        = accommodationAd.Content;
                model.PublishedDate  = accommodationAd.PublishedDate;
                model.ImageNames     = Accommodation.GetImageNames(accommodationAd.AdImages);
                model.ThumbnailNames = Accommodation.GetThumbnailNames(accommodationAd.Thumbnails);

                result.Add(model);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, new { Accommodations = result }));
        }
        // GET api/accommodation/id
        public HttpResponseMessage Get(int id)
        {
            AccommodationAd result = context.AccommodationAds.Find(id);

            if (result == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            AccommodationBindingModel model = new AccommodationBindingModel();

            model.Id             = result.Id;
            model.Author         = result.Author;
            model.Title          = result.Title;
            model.Content        = result.Content;
            model.PublishedDate  = result.PublishedDate;
            model.ImageNames     = Accommodation.GetImageNames(result.AdImages);
            model.ThumbnailNames = Accommodation.GetThumbnailNames(result.Thumbnails);

            return(Request.CreateResponse(HttpStatusCode.OK, model));
        }