Exemplo n.º 1
0
        public Task <ActionResult> GetUserByIdAsync(GetUserByIdParameters parameters, [FromServices] IGetUserByIdHandler handler, CancellationToken cancellationToken)
        {
            if (handler is null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            return(InvokeGetUserByIdAsync(parameters, handler, cancellationToken));
        }
Exemplo n.º 2
0
        public Task <GetUserByIdResult> ExecuteAsync(GetUserByIdParameters parameters, CancellationToken cancellationToken = default)
        {
            if (parameters is null)
            {
                throw new System.ArgumentNullException(nameof(parameters));
            }

            return(InvokeExecuteAsync(parameters, cancellationToken));
        }
Exemplo n.º 3
0
        private async Task <GetUserByIdResult> InvokeExecuteAsync(GetUserByIdParameters parameters, CancellationToken cancellationToken)
        {
            var data = new User
            {
                FirstName = "John",
                LastName  = "Doe",
                Email     = "*****@*****.**",
            };

            return(await Task.FromResult(data));
        }
Exemplo n.º 4
0
        public Task <GetUserByIdResult> ExecuteAsync(GetUserByIdParameters parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (parameters.Id == Guid.Parse("77a33260-0007-441f-ba60-b0a833803fab"))
            {
                return(Task.FromResult(GetUserByIdResult.NotFound($"Could not find user with id={parameters.Id}")));
            }

            return(InvokeExecuteAsync(parameters, cancellationToken));
        }
Exemplo n.º 5
0
        public Task <GetUserByIdResult> ExecuteAsync(GetUserByIdParameters parameters, CancellationToken cancellationToken = default)
        {
            var data = new User
            {
                Id             = Guid.Parse("77a33260-0000-441f-ba60-b0a833803fab"),
                Gender         = GenderType.Female,
                FirstName      = "Hallo",
                LastName       = "Hallo1",
                Email          = "*****@*****.**",
                Color          = ColorType.Red,
                HomeAddress    = new Address(),
                CompanyAddress = new Address(),
            };

            return(Task.FromResult(GetUserByIdResult.Ok(data)));
        }
Exemplo n.º 6
0
        public Task <GetUserByIdResult> ExecuteAsync(GetUserByIdParameters parameters, CancellationToken cancellationToken = default)
        {
            var data = new User
            {
                Id          = Guid.Parse("77a33260-0000-441f-ba60-b0a833803fab"),
                Gender      = GenderType.Female,
                FirstName   = "Hallo1",
                LastName    = "Hallo2",
                Email       = "*****@*****.**",
                Homepage    = new Uri("http://www.dr.dk"),
                Color       = ColorType.Red,
                HomeAddress = new Address
                {
                    StreetName   = "Hallo",
                    StreetNumber = "Hallo1",
                    PostalCode   = "Hallo2",
                    CityName     = "Hallo3",
                    MyCountry    = new Country
                    {
                        Name       = "Hallo1",
                        Alpha2Code = "Ha",
                        Alpha3Code = "Hal",
                    },
                },
                CompanyAddress = new Address
                {
                    StreetName   = "Hallo",
                    StreetNumber = "Hallo1",
                    PostalCode   = "Hallo2",
                    CityName     = "Hallo3",
                    MyCountry    = new Country
                    {
                        Name       = "Hallo1",
                        Alpha2Code = "Ha",
                        Alpha3Code = "Hal",
                    },
                },
            };

            return(Task.FromResult(GetUserByIdResult.Ok(data)));
        }
Exemplo n.º 7
0
 private static async Task <ActionResult> InvokeGetUserByIdAsync(GetUserByIdParameters parameters, IGetUserByIdHandler handler, CancellationToken cancellationToken)
 {
     return(await handler.ExecuteAsync(parameters, cancellationToken));
 }
Exemplo n.º 8
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        private async Task <GetUserByIdResult> InvokeExecuteAsync(GetUserByIdParameters parameters, CancellationToken cancellationToken)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        {
            throw new System.NotImplementedException();
        }