예제 #1
0
 private int InsertPlace(Place place)
 {
     var parameters = new TableCommunicationParameters("dbo.Places", ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, new List<string> { "Name", "Description", "OwnerId", "Longtitude", "Latitude" });
     IInsertCommuncitor communcitor = new InsertCommunicator(parameters);
     SqlPlaceModel sqlModel = new SqlPlaceModel(place);
     return communcitor.Insert(new CombinationFilter(new ValueFilterWithApostrophe(sqlModel.Name), new CombinationFilter(new CombinationFilter(new ValueFilterWithApostrophe(sqlModel.Description), new ValueFilter(sqlModel.OwnerId)), new CombinationFilter(new ValueFilter(sqlModel.Longtitude), new ValueFilter(sqlModel.Latitude)))));
 }
예제 #2
0
        private int GetPlace(Place place)
        {
            var parameters = new TableCommunicationParameters("dbo.Places", ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, new List<string>());

            int id = -1;
            using (var conn = new SqlConnection(parameters.ConnectionString))
            {
                conn.Open();
                using (SqlCommand command = new SqlCommand("dbo.GetMatchingPlaces", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("@lat", place.Position.Langtitude));
                    command.Parameters.Add(new SqlParameter("@lon", place.Position.Longtitude));
                    command.Parameters.Add(new SqlParameter("@maxDistance", 1));
                    command.Parameters.Add(new SqlParameter("@name", place.Name));

                    SqlParameter output = new SqlParameter("@id", SqlDbType.Int);
                    output.Direction = ParameterDirection.Output;
                    command.Parameters.Add(output);
                    command.ExecuteNonQuery();

                    id = (int)output.Value;
                }
            }
            return id;
        }
예제 #3
0
 public TableCommunicator(TableCommunicationParameters parameters)
 {
     connectionString = parameters.ConnectionString;
     tableName = parameters.TableName;
     columns = parameters.Columns;
 }
예제 #4
0
 public DeleteCommunicator(TableCommunicationParameters parameters)
     : base(parameters)
 {
 }
예제 #5
0
 public ReadCommunicator(TableCommunicationParameters parameters, Type modelType)
     : base(parameters)
 {
     _communicatorType = modelType;
 }
예제 #6
0
 public InsertCommunicator(TableCommunicationParameters paramerters)
     : base(paramerters)
 {
 }