public void Process(DataCollectorLocationChanged @event) { var updateRes = _dataCollectors.ChangeLocation( @event.DataCollectorId, @event.LocationLatitude, @event.LocationLongitude); }
public void Process(DataCollectorLocationChanged @event) { var dataCollector = _dataCollectors.GetById(@event.DataCollectorId); dataCollector.Location = new Location(@event.LocationLatitude, @event.LocationLongitude); _dataCollectors.Update(dataCollector); }
public void Process(DataCollectorLocationChanged @event) { var dataCollector = _dataCollectors.GetById(@event.DataCollectorId) ?? throw new Exception("Data collector with id " + @event.DataCollectorId + " was not found"); dataCollector.Location = new Location(@event.LocationLatitude, @event.LocationLongitude); _dataCollectors.Save(dataCollector); var res = _dataCollectors.UpdateOne( Builders <DataCollector> .Filter.Where(d => d.DataCollectorId == @event.DataCollectorId), Builders <DataCollector> .Update.Set(d => d.Location, new Location(@event.LocationLatitude, @event.LocationLongitude))); if (res.IsModifiedCountAvailable && res.MatchedCount < 1) { throw new Exception("Data collector with id " + @event.DataCollectorId + " was not found"); } }
public void Process(DataCollectorLocationChanged @event) { _dataCollectors.Update(d => d.Id == (DataCollectorId)@event.DataCollectorId, Builders <DataCollector> .Update.Set(d => d.Location, new Location(@event.LocationLatitude, @event.LocationLongitude))); }