public object Post(PrototypeExchange exchange) { return Repository.Store(exchange); }
private PrototypeExchange[] GenerateExchangePair() { var user1 = GetUserId(); var user2 = GetUserId(user1); var latitude = GetLatitude(); var longitude = GetLongitude(); var user1Exchange = new PrototypeExchange() { HorizontalAccuracy = random.NextDouble() * random.Next(1, 120), Latitude = latitude, Longitude = longitude, UserId = user1, TargetUserId = user2, LocationFreshnessInSeconds = random.NextDouble() * random.Next(1, 300) }; var user2Exchange = new PrototypeExchange() { HorizontalAccuracy = random.NextDouble() * random.Next(1, 120), Latitude = latitude, Longitude = longitude, UserId = user2, TargetUserId = user1, LocationFreshnessInSeconds = random.NextDouble() * random.Next(1, 300) }; return new[] { user1Exchange, user2Exchange }; }
public PrototypeExchange Store(PrototypeExchange exchange) { using (var dbConnection = _dbFactory.OpenDbConnection()) { if (exchange.Id == null) { exchange.Id = Guid.NewGuid().ToString("N"); dbConnection.Insert(exchange); } else dbConnection.Update(exchange); } return exchange; }