/// <summary>Handles a request</summary> /// <param name="request">The request</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>Response from the request</returns> public async Task <Unit> Handle(PriceGenerateRequest request, CancellationToken cancellationToken) { // Some operations with entities // Update database with new rates // using UnitOfWork instance (_unitOfWork) // EXAMPLE: // ---------------------------------------------------------------------------- // await _unitOfWork.SaveChangesAsync(); // if (!_unitOfWork.LastSaveChangesResult.IsOk) // { // await _workService.WorkFailedAsync(cancellationToken, request.WorkId, _unitOfWork.LastSaveChangesResult.Exception); // return Unit.Value; // // ---------------- OR -------------------------- // await _workService.RestartWorkAsync(request.WorkId, _unitOfWork.LastSaveChangesResult.Exception.Message); // return Unit.Value; // } // Finishing the work await _workService.CompleteWorkAsync(cancellationToken, request.WorkId, "Price generation completed"); // and append new work for price generation await _worker.AppendWorkPriceSendingAsync(cancellationToken); // return return(Unit.Value); }
/// <summary>Handles a request</summary> /// <param name="request">The request</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>Response from the request</returns> public async Task <Unit> Handle(DownloadRatesRequest request, CancellationToken cancellationToken) { // Some operations with IEmailService and IProfileService // Update database with new rates // using UnitOfWork instance (_unitOfWork) // EXAMPLE: // ---------------------------------------------------------------------------- // await _unitOfWork.SaveChangesAsync(); // if (!_unitOfWork.LastSaveChangesResult.IsOk) // { // await _workService.WorkFailedAsync(cancellationToken, request.WorkId, _unitOfWork.LastSaveChangesResult.Exception); // return Unit.Value; // // ---------------- OR -------------------------- // await _workService.RestartWorkAsync(request.WorkId, _unitOfWork.LastSaveChangesResult.Exception.Message); // return Unit.Value; // } // Finishing the work await _workService.CompleteWorkAsync(cancellationToken, request.WorkId, "Updated from Bank of Russia"); // append work for rates generation await _worker.AppendWorkPriceCalculationAsync(cancellationToken); // return return(Unit.Value); }
/// <summary>Handles a request</summary> /// <param name="request">The request</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>Response from the request</returns> public async Task <Unit> Handle(PriceSendRequest request, CancellationToken cancellationToken) { // Some operations with IEmailService and IProfileService // Update database with new rates // using UnitOfWork instance (_unitOfWork) // EXAMPLE: // ---------------------------------------------------------------------------- // await _unitOfWork.SaveChangesAsync(); // if (!_unitOfWork.LastSaveChangesResult.IsOk) // { // await _workService.WorkFailedAsync(cancellationToken, request.WorkId, _unitOfWork.LastSaveChangesResult.Exception); // return Unit.Value; // // ---------------- OR -------------------------- // await _workService.RestartWorkAsync(request.WorkId, _unitOfWork.LastSaveChangesResult.Exception.Message); // return Unit.Value; // } // Finishing the work await _workService.CompleteWorkAsync(cancellationToken, request.WorkId, "13202395 email sent"); // return return(Unit.Value); }