Ejemplo n.º 1
0
        public HttpResponseMessage Regions()
        {
            //returns a list of vintages

            using (WineDBEntities wdb = new WineDBEntities())
            {
                var Regions = wdb.Regions;
                List<RegionDTO> lm = new List<RegionDTO>();
                foreach (var region in Regions)
                {
                    lm.Add(new RegionDTO { AreaName = region.Name, Country = region.Country, RegionId = region.RegionId });
                }
                return Request.CreateResponse(HttpStatusCode.OK, lm);
            }
        }
Ejemplo n.º 2
0
        public ServiceResponseMessage List(ServiceResponseMessage newRequest)
        {
            this.request = newRequest;
            using (WineDBEntities wdb = new WineDBEntities()) {

                var regions = wdb.Regions;
                RegionList rl = new RegionList();

                rl.Regions = new List<RegionDTO>();

                foreach (var rv in regions)
            {
                rl.Regions.Add(new RegionDTO() { RegionId = rv.RegionId, AreaName = rv.Name, Country = rv.Country, OldestVintage = rv.Vintages.Min(x=>x.Year)});
            }

            request.RequestObject = rl;
            //request.ElapsedTime = sw.Elapsed.Milliseconds;

            return request;
            }
        }