public Task <bool> Handle(RemoveWorkAvailabilityCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(Task.FromResult(false)); } var model = waRepository.GetById(request.Id); if (model == null) { NotifyValidationErrors(request); return(Task.FromResult(false)); } model.EntityState = EntityStateOptions.Deleted; waRepository.Update(model); if (Commit()) { bus.RaiseEvent(new WorkAvailabilityRemovedEvent(model.Id)); } return(Task.FromResult(true)); }
public void Remove(int id) { var removeCommand = new RemoveWorkAvailabilityCommand(id); bus.SendCommand(removeCommand); }