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));
     }
 }
Пример #3
0
 public async Task <BeaconV1> UpdateAsync(string correlationId, BeaconV1 beacon)
 {
     return(await SafeInvokeAsync(correlationId, "UpdateAsync", () =>
     {
         return _Persistence.UpdateAsync(correlationId, beacon);
     }));
 }
Пример #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);
        }
Пример #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);
 }
Пример #6
0
 public async Task <BeaconV1> UpdateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await CallCommandAsync <BeaconV1>(
                "update_beacon",
                correlationId,
                new
     {
         beacon = beacon
     }
                ));
 }
Пример #7
0
 public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await CallCommandAsync <BeaconV1>(
                "create_beacon",
                correlationId ?? IdGenerator.NextLong(),
                new
     {
         beacon = beacon
     }
                ));
 }
Пример #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));
        }
Пример #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);
        }
Пример #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));
        }
Пример #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()));
 }
Пример #15
0
 public async Task <BeaconV1> CreateBeaconAsync(string correlationId, BeaconV1 beacon)
 {
     return(await Task.FromResult <BeaconV1>(null));
 }