コード例 #1
0
ファイル: StingsController.cs プロジェクト: theAppleist/Sting
 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
ファイル: PlacesController.cs プロジェクト: theAppleist/Sting
        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
ファイル: Sting.cs プロジェクト: theAppleist/Sting
 public Sting(int stingId, User user, Place place, DateTime timestamp, string description, double price)
 {
     StingId = stingId;
     User = user;
     Place = place;
     Timestamp = timestamp;
     Description = description;
     Price = price;
 }
コード例 #4
0
ファイル: SqlPlaceModel.cs プロジェクト: theAppleist/Sting
 public SqlPlaceModel(Place place)
 {
     Id = place.PlaceId;
     Name = place.Name;
     Description = place.Description;
     OwnerId = place.Owner.UserId;
     Longtitude = (float)place.Position.Longtitude;
     Latitude = (float)place.Position.Langtitude;
 }
コード例 #5
0
ファイル: PlacesController.cs プロジェクト: theAppleist/Sting
 public int PostPlace(Place place)
 {
     //    var id = GetPlace(place);
     //    if (id == -1)
     //    {
     //        return InsertPlace(place);
     //    }
     //    return id;
     ITableCrudMethods<Place> crud = new PlacesTableCrud();
     return crud.Insert(place);
 }