public async Task <int> Handle(SaveOperationRequestCommand request, CancellationToken cancellationToken) { var operationRequest = new AccountOperationRequest() { AccountId = request.AccountId, CreationDate = DateTime.UtcNow, Note = request.Note, OperationType = request.Type, OperationDate = request.OperationDate, Amount = request.Amount, Status = AccountOperationStatus.Created, }; operationRequest.Validate(); if (!operationRequest.Valid) { _notificationContext.AddNotifications(operationRequest.ValidationResult); return(default(int)); } _accountOperationRequestRepository.Add(operationRequest); await _unitOfWork.CommitAsync(); operationRequest.JobReferenceId = _jobClient.Enqueue <IPerformOperationRequestJob> (job => job.PerformOperation(operationRequest.Id), request.OperationDate); _accountOperationRequestRepository.Update(operationRequest); await _unitOfWork.CommitAsync(); return(operationRequest.Id); }
public void Add() { //mediator.Publish(new Com.StarZ.MediatR.DemoNotification() { Message = DateTime.Now.ToString()}); Console.WriteLine($"Add {DateTime.Now.ToString()}"); jobClient.Enqueue(() => Console.WriteLine($"JOB {DateTime.Now.ToString()}")); }