示例#1
0
        private async Task <List <dto.StockistModel> > GetStockists(string area)
        {
            var ret = new List <dto.StockistModel>();

            var cmd = this.MySqlDB.Connection.CreateCommand() as MySqlCommand;

            string query = @"SELECT StockistID, StockistName, StockistStreet, StockistSuburb, StockistCity, StockistPhoneNumber, StockistURL  FROM stockists where stockistcity = '" + area + "'";

            System.Diagnostics.Debug.WriteLine(query);

            cmd.CommandText = query;



            using (var reader = await cmd.ExecuteReaderAsync())
                while (await reader.ReadAsync())
                {
                    var t = new dto.StockistModel()
                    {
                        StockistId          = reader.GetFieldValue <int>(0),
                        StockistName        = reader.GetFieldValue <string>(1),
                        StockistStreet      = reader.GetFieldValue <string>(2),
                        StockistSuburb      = reader.GetFieldValue <string>(3),
                        StockistCity        = reader.GetFieldValue <string>(4),
                        StockistPhoneNumber = reader.GetFieldValue <string>(5),
                        StockistURL         = reader.GetFieldValue <string>(6)
                    };

                    ret.Add(t);
                }
            return(ret);
        }
示例#2
0
        private async Task <List <dto.StockistModel> > GetAreas()
        {
            var ret = new List <dto.StockistModel>();

            var cmd = this.MySqlDB.Connection.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT Distinct StockistCity FROM Stockists;";

            using (var reader = await cmd.ExecuteReaderAsync())
                while (await reader.ReadAsync())
                {
                    var t = new dto.StockistModel()
                    {
                        StockistCity = reader.GetFieldValue <string>(0)
                    };

                    ret.Add(t);
                }
            return(ret);
        }