Exemple #1
0
        public Task <bool> Handle(RegisterSimpleTreatmentMachineCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(Task.FromResult(false));
            }

            var treatmentMachine = new TreatmentMachine(Guid.NewGuid(), request.Name, TreatmentMachineType.Simple);

            _treatmentMachineRepository.Add(treatmentMachine);

            if (Commit())
            {
                _mediator.RaiseEvent(new TreatmentMachineSimpleRegisteredEvent(treatmentMachine.Id, treatmentMachine.Name));
            }

            return(Task.FromResult(true));
        }