Exemplo n.º 1
0
        public string GetAllDeals()
        {
            List<Deal> deals;

            using (var entities = new sunday_driveEntities())
            {
                deals = (from d in entities.Deals select d).ToList();
                deals.ForEach(d => entities.Detach(d));
            }
            return new JavaScriptSerializer().Serialize(deals);
        }
Exemplo n.º 2
0
 public string GetBusinessDeals(int businessID)
 {
     List<Deal> deals;
     using (var entities = new sunday_driveEntities())
     {
         deals = (from d in entities.Deals
                  where d.BusinessID == businessID
                  select d).ToList();
         deals.ForEach(d => entities.Detach(d));
     }
     return new JavaScriptSerializer().Serialize(deals); ;
 }
Exemplo n.º 3
0
        public string ExampleQuery1()
        {
            List<Business> businesses;

            using (var entities = new sunday_driveEntities())
            {
                businesses = entities.Businesses.Where(b => b.PriceLevel > 2).ToList();

                businesses.ForEach(b => entities.Detach(b)); // This line is needed to prevent circular references when serializing to Json.
            }

            return new JavaScriptSerializer().Serialize(businesses);
        }
Exemplo n.º 4
0
        public string GetBusinessesByPriceLevel(int priceLevel)
        {
            List<Business> businesses;

            using (var entities = new sunday_driveEntities())
            {
                businesses = (from b in entities.Businesses
                             where b.PriceLevel <= priceLevel
                             select b).ToList();

                businesses.ForEach(b => entities.Detach(b)); // This line is needed to prevent circular references when serializing to Json.
            }

            return new JavaScriptSerializer().Serialize(businesses);
        }
Exemplo n.º 5
0
        public string GetBusinessRatings(int businessID)
        {
            List<Rating> ratings;
            using (var entities = new sunday_driveEntities())
            {
                ratings = (from r in entities.Ratings
                           where entities.Locations.Any(l => l.LocationID == r.LocationID && l.BusinessID == businessID)
                           select r).ToList();
                ratings.ForEach(r => entities.Detach(r));
            }

            return new JavaScriptSerializer().Serialize(ratings);
        }
Exemplo n.º 6
0
        public void InsertRating(int locationID, int rating, string review)
        {
            using (var entities = new sunday_driveEntities())
            {
                Rating newRating = new Rating();
                newRating.LocationID = locationID;
                newRating.Rating1 = rating;
                newRating.Text = review;

                entities.Ratings.AddObject(newRating);

                entities.SaveChanges();
            }
        }
Exemplo n.º 7
0
        public void InsertLocation(int businessID, string street1, string street2, string municipality, string county, string state, string postalcode, string country, string phone)
        {
            using (var entities = new sunday_driveEntities())
            {
                Location newLocation = new Location()
                {
                    BusinessID = businessID,
                    StreetLine1 = street1,
                    StreetLine2 = street2,
                    Municipality = municipality,
                    County = county,
                    State = state,
                    PostalCode = postalcode,
                    Country = country,
                    Phone = phone
                };

                SetGPSCoords(ref newLocation);

                entities.Locations.AddObject(newLocation);

                entities.SaveChanges();
            }
        }
Exemplo n.º 8
0
        public string GetLocations(int businessID)
        {
            List<Location> locations;

            using (var entities = new sunday_driveEntities())
            {
                locations = (from l in entities.Locations
                             where l.BusinessID == businessID
                             select l).ToList();

                locations.ForEach(l => entities.Detach(l)); // This line is needed to prevent circular references when serializing to Json.
            }
            return new JavaScriptSerializer().Serialize(locations);
        }
Exemplo n.º 9
0
        public string GetLocationRatings(int locationID)
        {
            List<Rating> ratings;

            using (var entities = new sunday_driveEntities())
            {
                ratings = (from r in entities.Ratings
                           where r.LocationID == locationID
                           select r).ToList();

                ratings.ForEach(r => entities.Detach(r)); // This line is needed to prevent circular references when serializing to Json.
            }

            return new JavaScriptSerializer().Serialize(ratings);
        }