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