public async Task Remove(Guid?id) { var doctorRemove = new RemoveDoctorCommand(id.Value); if (doctorRemove == null) { throw new Exception($"Doutor não encontrado."); } await _mediator.Send(doctorRemove); }
public Task Handle(RemoveDoctorCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.CompletedTask); } _doctorRepository.Remove(message.DoctorId); if (Commit()) { Bus.RaiseEvent(new DoctorRemovedEvent(message.DoctorId)); } return(Task.CompletedTask); }
public Task <bool> Handle(RemoveDoctorCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(Task.FromResult(false)); } if (_doctorRepository.isDoctorReservedInTheFuture(request.Id)) { _mediator.RaiseEvent(new DomainNotification(request.MessageType, "Doctor's timetable has to be cleared first.")); return(Task.FromResult(false)); } _doctorRepository.Remove(request.Id); if (Commit()) { _mediator.RaiseEvent(new DoctorRemovedEvent(request.Id)); } return(Task.FromResult(true)); }
public void Remove(int id) { var removeCommand = new RemoveDoctorCommand(id); Bus.SendCommand(removeCommand); }
public void Remove(Guid id) { var removeDoctorCommand = new RemoveDoctorCommand(id); _mediator.SendCommand(removeDoctorCommand); }