public async Task DeleteAsync(Climb climb)
 {
     await _deleteClimbCommand.ExecuteAsync(new DeleteClimbCommandParameters
     {
         Id = climb.Id
     }, _database.GetCollection<Climb>("climbs"));
 }
        public async Task<Climb> UpsertAsync(Climb climb)
        {
            await _upsertClimbCommand.ExecuteAsync(new UpsertClimbCommandParameters
            {
                Id = climb.Id,
                LatLong = climb.LatLong,
                Styles = climb.Styles,
                Rating = climb.Rating
            }, _database.GetCollection<Climb>("climbs"));

            return climb;
        }
        public async Task<IHttpActionResult> Post(UpsertClimbRequest request)
        {
            var climb = new Climb
            {
                LatLong = new LatLong
                {
                    Latitude = request.LatLong.Latitude,
                    Longitude = request.LatLong.Longitude
                },
                Styles = request.Styles
            };

            var result = await Upsert(climb);

            return Ok(result.ToResponse());
        }
        public async Task ExecuteAsync(UpsertClimbCommandParameters parameters, IMongoCollection<Climb> collection)
        {
            var climb = new Climb
            {
                Id = parameters.Id,
                LatLong = parameters.LatLong,
                Rating = parameters.Rating,
                Styles = parameters.Styles,
                Name = parameters.Name
            };

            if (parameters.Id == Guid.Empty)
            {
                await collection.InsertOneAsync(climb);
            }
            else
            {
                var filter = Builders<Climb>.Filter.Eq(c => c.Id == climb.Id, true);
                await collection.UpdateOneAsync(filter, new ObjectUpdateDefinition<Climb>(climb));
            }
        }
 private async Task<Climb> Upsert(Climb climb)
 {
     return await _climbRepository.UpsertAsync(climb);
 }