public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
        {
            beacon.Id   = beacon.Id ?? IdGenerator.NextLong();
            beacon.Type = beacon.Type ?? BeaconTypeV1.Unknown;

            return(await _persistence.CreateAsync(correlationId, beacon));
        }
 public async Task <BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     using (Instrument(correlationId, "beacons.update_beacon"))
     {
         return(await _controller.UpdateBeaconAsync(correlationId, beacon));
     }
 }
Esempio n. 3
0
 public async Task <BeaconV1> UpdateAsync(string correlationId, BeaconV1 beacon)
 {
     return(await SafeInvokeAsync(correlationId, "UpdateAsync", () =>
     {
         return _Persistence.UpdateAsync(correlationId, beacon);
     }));
 }
Esempio n. 4
0
        private static BeaconsMongoDbSchema FromPublic(BeaconV1 val)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <BeaconV1, BeaconsMongoDbSchema>());
            var mapper = config.CreateMapper();
            BeaconsMongoDbSchema result = mapper.Map <BeaconsMongoDbSchema>(val);

            return(result);
        }
Esempio n. 5
0
 public static void AssertEqual(BeaconV1 expectedBeacon, BeaconV1 actualBeacon)
 {
     Assert.Equal(expectedBeacon.Id, actualBeacon.Id);
     Assert.Equal(expectedBeacon.SiteId, actualBeacon.SiteId);
     Assert.Equal(expectedBeacon.Type, actualBeacon.Type);
     Assert.Equal(expectedBeacon.Udi, actualBeacon.Udi);
     Assert.Equal(expectedBeacon.Label, actualBeacon.Label);
     Assert.Equal(expectedBeacon.Center, actualBeacon.Center);
     Assert.Equal(expectedBeacon.Radius, actualBeacon.Radius);
 }
Esempio n. 6
0
 public async Task <BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await CallCommandAsync <BeaconV1>(
                "update_beacon",
                correlationId,
                new
     {
         beacon = beacon
     }
                ));
 }
Esempio n. 7
0
 public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await CallCommandAsync <BeaconV1>(
                "create_beacon",
                correlationId ?? IdGenerator.NextLong(),
                new
     {
         beacon = beacon
     }
                ));
 }
Esempio n. 8
0
        public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
        {
            if (beacon == null)
            {
                return(null);
            }

            beacon.Id = beacon.Id ?? IdGenerator.NextLong();
            _items.Add(beacon);

            return(await Task.FromResult(beacon));
        }
Esempio n. 9
0
        private BeaconV1 ToPublic(BeaconsMongoDbSchema val)
        {
            if (val == null)
            {
                return(null);
            }
            var      config = new MapperConfiguration(cfg => cfg.CreateMap <BeaconsMongoDbSchema, BeaconV1>());
            var      mapper = config.CreateMapper();
            BeaconV1 result = mapper.Map <BeaconV1>(val);

            return(result);
        }
Esempio n. 10
0
        public async Task <BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon)
        {
            var index = _items.FindIndex(el => el.Id == beacon.Id);

            if (index < 0)
            {
                return(null);
            }

            _items[index] = beacon;

            return(await Task.FromResult(beacon));
        }
        public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
        {
            var methodName = "beacons.create_beacon";

            try
            {
                using (Instrument(correlationId, methodName))
                {
                    return(await _controller.CreateBeaconAsync(correlationId, beacon));
                }
            }
            catch (Exception ex)
            {
                InstrumentError(correlationId, methodName, ex);
                throw ex;
            }
        }
        public async Task <BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon)
        {
            beacon.Type = beacon.Type ?? BeaconTypeV1.Unknown;

            return(await _persistence.UpdateAsync(correlationId, beacon));
        }
Esempio n. 13
0
        public async Task <BeaconV1> UpdateAsync(string correlationId, BeaconV1 beacon)
        {
            var result = await UpdateAsync(correlationId, FromPublic(beacon));

            return(ToPublic(result));
        }
 public async Task <BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await Task.FromResult(new BeaconV1()));
 }
Esempio n. 15
0
 public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await Task.FromResult <BeaconV1>(null));
 }