public async Task Handle(T message) { DataContext.PushCurrent(lookup.Get(localDbName)); await inner.Handle(message); DataContext.PopCurrent(); }
public async Task <IHttpActionResult> ScanFolderForShows(List <string> foldersToScan) { ScanShows scanShows = new ScanShows() { FoldersToScan = foldersToScan }; return(Ok(await _handler.Handle(scanShows))); }
public async Task <IHttpActionResult> ScanFolderForMovies([FromUri] List <string> foldersToScan) { ScanMovies scanMovies = new ScanMovies() { FoldersToScan = foldersToScan }; return(Ok(await _handler.Handle(scanMovies))); }
public async Task <IHttpActionResult> UpdateStudent() { await _updateStudent.Handle(new UpdateStudentCommand { Id = 2, FirstName = "Judge", LastName = "Dredd" }); return(Ok()); }
public async Task Handle(TCommand command, CancellationToken cancellationToken = default) { if (command == null) { throw new ArgumentNullException(nameof(command)); } command.EnsureIsValid(); await asyncCommandHandler.Handle(command, cancellationToken).ConfigureAwait(false); }
public async Task <IHttpActionResult> CreateStudent() { var command = new CreateStudentCommand { FirstName = "Check", LastName = "This" }; await _createStudent.Handle(command); // retunr the new student id from the command return(Ok(command.Id)); }
public async Task <TCommandResult> Handle <TCommand, TCommandResult>(TCommand command) where TCommand : ICommand where TCommandResult : ICommandResult, new() { bool async = false; IAsyncCommandHandler <TCommand, TCommandResult> asyncHandler = null; ICommandHandler <TCommand, TCommandResult> handler = _serviceProvider.GetService(typeof(ICommandHandler <TCommand, TCommandResult>)) as ICommandHandler <TCommand, TCommandResult>; if (handler == null) { async = true; asyncHandler = _serviceProvider.GetService(typeof(IAsyncCommandHandler <TCommand, TCommandResult>)) as IAsyncCommandHandler <TCommand, TCommandResult>; } if (handler == null && asyncHandler == null) { throw new ArgumentNullException(nameof(handler)); } TCommandResult result = new TCommandResult(); try { _logService.Log <ICommandHandler <TCommand, TCommandResult> >(nameof(EOperations.Input), nameof(handler.Handle), new { Input = command }, LogLevel.Debug); result = async ? await asyncHandler.Handle(command) : handler.Handle(command); if (result == null) { result = new TCommandResult(); IReadOnlyDictionary <string, IReadOnlyCollection <INotificationMessage> > notifications = async ? asyncHandler.Notifications : handler.Notifications; if (notifications.Count > 0) { result.Populate(InvalidHandlerDefaultCode, notifications); } } } catch (Exception exception) { _logService.Log <ICommandHandler <TCommand, TCommandResult> >(exception, new { Input = command }, LogLevel.Error); } finally { _logService.Log <ICommandHandler <TCommand, TCommandResult> >(nameof(EOperations.Output), nameof(handler.Handle), new { Output = result }, LogLevel.Debug); } return(result); }
public Task <EnableUserResponse> Enable([FromRoute] EnableUserCommand query) { return(_enableUserCommandHandler.Handle(query)); }
public Task <DisableUserResponse> Disable([FromRoute] DisableUserCommand query) { return(_disableUserCommandHandler.Handle(query)); }
public async Task <DeleteMealResponse> Delete([FromRoute] DeleteMealCommand command) { return(await _deleteMealCommandHandler.Handle(command)); }
public Task <DeleteUserMealsReponse> Get([FromBody] DeleteUserMealsCommand command) { return(_deleteUserMeals.Handle(command)); }
public async Task Handle(TCommand command) { await _decorated.Handle(command); await _uow.SaveChangesAsync(); }
public async Task <IHttpActionResult> DeleteStudent(int id) { await _deleteStudent.Handle(new DeleteStudentCommand { Id = id }); return(Ok()); }
public Task <EditProductResponse> Edit([FromBody] EditProductCommand command) { return(_editProductCommandHandler.Handle(command)); }
public Task <AddProductResponse> Add([FromBody] AddProductCommand command) { return(_addProductCommandHandler.Handle(command)); }
public Task <RegisterUserResponse> Register(RegisterUserCommand command) { return(_registerUserCommandHandler.Handle(command)); }
public Task <LoginUserResponse> Login(LoginUserCommand command) { return(_loginUserCommandHandler.Handle(command)); }
public async Task <IHttpActionResult> PostAsync(CommitSynchronisation toPost) { await commandHandler.Handle(new CommitSynchronisableCommits { Synchronisation = toPost }); return(Ok()); }
public Task <AddUserMealResponse> Add([FromBody] AddUserMealCommand command) { command.UserId = User.Claims.First(c => c.Type == "UserID").Value; return(_addUserMealCommandHandler.Handle(command)); }
public Task <AddMealResponse> Add([FromBody] AddMealCommand command) { return(_addMealCommandHandler.Handle(command)); }
public async Task Handle(TCommand command, CancellationToken cancellationToken = default) { await CreateAsyncPolicy() .ExecuteAsync(async() => await asyncCommandHandler.Handle(command, cancellationToken)); }
public async Task <EditMealResponse> Edit([FromBody] EditMealCommand command) { return(await _editMealCommandHandler.Handle(command)); }