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))))); }
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; }
public TableCommunicator(TableCommunicationParameters parameters) { connectionString = parameters.ConnectionString; tableName = parameters.TableName; columns = parameters.Columns; }
public DeleteCommunicator(TableCommunicationParameters parameters) : base(parameters) { }
public ReadCommunicator(TableCommunicationParameters parameters, Type modelType) : base(parameters) { _communicatorType = modelType; }
public InsertCommunicator(TableCommunicationParameters paramerters) : base(paramerters) { }