//Idempotent method
        public async Task <Unit> Handle(UpdateSensorCommand request, CancellationToken cancellationToken)
        {
            var model = await _snapShotRepository.GetAsync(request.Id);

            if (model == default || (model.FarmId == request.FarmId && model.State == request.State))
            {
                return(Unit.Value);
            }
            model.FarmId = request.FarmId;
            model.State  = request.State;

            await _snapShotRepository.SaveAsync(model);

            await _eventRepository.UpdateAsync(model);

            return(Unit.Value);
        }
예제 #2
0
 public Task <Sensor> Handle(GetSensorQuery request, CancellationToken cancellationToken)
 {
     return(_snapShotRepository.GetAsync(request.Id));
 }