//Idempotent method
        public async Task <Unit> Handle(UpdateCowCommand 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);
        }
Exemplo n.º 2
0
 public Task <Cow> Handle(GetCowQuery request, CancellationToken cancellationToken)
 {
     return(_snapShotRepository.GetAsync(request.Id));
 }