public async Task Handle(T message)
        {
            DataContext.PushCurrent(lookup.Get(localDbName));
            await inner.Handle(message);

            DataContext.PopCurrent();
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> ScanFolderForShows(List <string> foldersToScan)
        {
            ScanShows scanShows = new ScanShows()
            {
                FoldersToScan = foldersToScan
            };

            return(Ok(await _handler.Handle(scanShows)));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> ScanFolderForMovies([FromUri] List <string> foldersToScan)
        {
            ScanMovies scanMovies = new ScanMovies()
            {
                FoldersToScan = foldersToScan
            };

            return(Ok(await _handler.Handle(scanMovies)));
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> UpdateStudent()
        {
            await _updateStudent.Handle(new UpdateStudentCommand {
                Id        = 2,
                FirstName = "Judge",
                LastName  = "Dredd"
            });

            return(Ok());
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public Task <EnableUserResponse> Enable([FromRoute] EnableUserCommand query)
 {
     return(_enableUserCommandHandler.Handle(query));
 }
Ejemplo n.º 9
0
 public Task <DisableUserResponse> Disable([FromRoute] DisableUserCommand query)
 {
     return(_disableUserCommandHandler.Handle(query));
 }
Ejemplo n.º 10
0
 public async Task <DeleteMealResponse> Delete([FromRoute] DeleteMealCommand command)
 {
     return(await _deleteMealCommandHandler.Handle(command));
 }
Ejemplo n.º 11
0
 public Task <DeleteUserMealsReponse> Get([FromBody] DeleteUserMealsCommand command)
 {
     return(_deleteUserMeals.Handle(command));
 }
Ejemplo n.º 12
0
        public async Task Handle(TCommand command)
        {
            await _decorated.Handle(command);

            await _uow.SaveChangesAsync();
        }
Ejemplo n.º 13
0
        public async Task <IHttpActionResult> DeleteStudent(int id)
        {
            await _deleteStudent.Handle(new DeleteStudentCommand { Id = id });

            return(Ok());
        }
Ejemplo n.º 14
0
 public Task <EditProductResponse> Edit([FromBody] EditProductCommand command)
 {
     return(_editProductCommandHandler.Handle(command));
 }
Ejemplo n.º 15
0
 public Task <AddProductResponse> Add([FromBody] AddProductCommand command)
 {
     return(_addProductCommandHandler.Handle(command));
 }
Ejemplo n.º 16
0
 public Task <RegisterUserResponse> Register(RegisterUserCommand command)
 {
     return(_registerUserCommandHandler.Handle(command));
 }
Ejemplo n.º 17
0
 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());
        }
Ejemplo n.º 19
0
 public Task <AddUserMealResponse> Add([FromBody] AddUserMealCommand command)
 {
     command.UserId = User.Claims.First(c => c.Type == "UserID").Value;
     return(_addUserMealCommandHandler.Handle(command));
 }
Ejemplo n.º 20
0
 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));
 }
Ejemplo n.º 22
0
 public async Task <EditMealResponse> Edit([FromBody] EditMealCommand command)
 {
     return(await _editMealCommandHandler.Handle(command));
 }