Ejemplo n.º 1
0
 public Market(String name, String address, MarketChain marketChain, GeoPolygon locationArea)
 {
     Name         = name;
     Address      = address;
     MarketChain  = marketChain;
     LocationArea = locationArea;
 }
Ejemplo n.º 2
0
        public Market GetMarketByID(Int64 marketID)
        {
            String query = string.Format(@"
                   SELECT {0}market.id AS mid, {0}market.name AS mname, {0}market.address,
                          {0}marketchain.id AS mcid, {0}marketchain.name AS mcname,
                          {0}location.id as lid, {0}location.longitude, {0}location.latitude, {0}location.accuracy, 
                          {0}market_location.order
                   FROM   {0}market
                   JOIN   {0}marketchain ON {0}market.chainID = {0}marketchain.id
                   JOIN   {0}market_location ON {0}market_location.marketID = {0}market.id
                   JOIN   {0}location ON {0}market_location.locationID = {0}location.id
                    AND   {0}market.id = @id
                   ORDER BY {0}market_location.order ASC", TablePrefix);

            var data = (List <object>)connection.Query(query, new { id = marketID }).ToList();

            List <GeoLocation> vertices = new List <GeoLocation>();

            foreach (var item in data)
            {
                var dataSet = (IDictionary <string, object>)item;
                vertices.Add(new GeoLocation((long)dataSet["lid"], (double)dataSet["longitude"], (double)dataSet["latitude"], (int)dataSet["accuracy"]));
            }
            GeoPolygon locationArea = new GeoPolygon(vertices);

            var         first  = (IDictionary <string, object>)data.First();
            MarketChain mchain = new MarketChain((long)first["mcid"], (string)first["mcname"]);
            Market      market = new Market((long)first["mid"], (string)first["mname"], (string)first["address"], mchain, locationArea);

            return(market);
        }
Ejemplo n.º 3
0
 public Market(Int64 id, String name, String address, MarketChain marketChain, GeoPolygon locationArea)
     : this(name, address, marketChain, locationArea)
 {
     ID = id;
 }