Esempio n. 1
0
 public object Post(PrototypeExchange exchange)
 {
     return Repository.Store(exchange);
 }
Esempio n. 2
0
        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
                };
        }
Esempio n. 3
0
        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;
        }