コード例 #1
0
 public async Task <CalculatedPriceResponse> Get(Guid productId)
 {
     return(await QueryBus.Execute <GetCalculatedPriceQuery, CalculatedPriceResponse>(new GetCalculatedPriceQuery
     {
         ProductId = productId
     }));
 }
コード例 #2
0
        public async Task <CategoriesResponse> GetAll()
        {
            var categoriesQuery    = new CategoriesQuery();
            var categoriesResponse = await QueryBus.Execute <CategoriesQuery, CategoriesResponse>(categoriesQuery);

            return(categoriesResponse);
        }
コード例 #3
0
 public async Task <LocalizationObjectResponse> GetLocalizationObject(CultureInfo culture, string category = null)
 {
     return(await QueryBus.Execute <LocalizationObjectQuery, LocalizationObjectResponse>(new LocalizationObjectQuery
     {
         Culture = culture,
         Category = category
     }));
 }
コード例 #4
0
        public async Task <ProductsWithPricesResponse> GetProducts(int page = 0, int itemsPerPage = 10)
        {
            var productsWithPricesQuery = new ProductsWithPricesQuery
            {
                ItemsOnPage = itemsPerPage,
                Page        = page
            };

            return(await QueryBus.Execute <ProductsWithPricesQuery, ProductsWithPricesResponse>(productsWithPricesQuery));
        }
コード例 #5
0
        public async Task <AccessTokenModel> LogIn(string email, string password)
        {
            var query = new UserIdByCredentialsQuery
            {
                Email    = email,
                Password = _sha512Service.Calculate(password)
            };

            var userIdResponse = await QueryBus.Execute <UserIdByCredentialsQuery, UserIdByCredentialsResponse>(query);

            var accessToken = await GenerateRefreshAndAccessToken(userIdResponse.UserId);

            return(accessToken);
        }
コード例 #6
0
        public async Task <AccessTokenModel> RefreshToken(string refreshToken, string accessToken)
        {
            var userId = _accessTokenService.GetPayload <AuthPayload>(accessToken).UserId;

            var refreshTokenResponse = await QueryBus.Execute <UserRefreshTokenQuery, UserRefreshTokenResponse>(
                new UserRefreshTokenQuery
            {
                UserId = userId
            });

            if (refreshToken != refreshTokenResponse.RefreshToken)
            {
                //TODO
                throw new NotImplementedException();
            }

            return(await GenerateRefreshAndAccessToken(userId));
        }
コード例 #7
0
        public async Task <LoginResponseModel> Login(LoginRequestModel model)
        {
            var customerIdByCredentialsQuery = new CustomerIdByCredentialsQuery
            {
                Email    = model.Email,
                Password = _sha512Service.Calculate(model.Password)
            };

            var customerIdResponse =
                await QueryBus.Execute <CustomerIdByCredentialsQuery, CustomerIdResponse>(customerIdByCredentialsQuery);

            var token = _tokenService.Create(new TokenPayload
            {
                CustomerId = customerIdResponse.Id
            });

            return(new LoginResponseModel
            {
                Token = token
            });
        }
コード例 #8
0
        public override async Task <HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext,
                                                                      CancellationToken cancellationToken)
        {
            if (!controllerContext.Request.Headers.TryGetValues("AccessToken", out var allTokens))
            {
                throw new AuthorizationRequiredException();
            }

            var token = allTokens.First();

            var payload = _accessTokenService.GetPayload <AuthPayload>(token);

            var refreshTokenResponse = await QueryBus.Execute <UserRefreshTokenQuery, UserRefreshTokenResponse>(
                new UserRefreshTokenQuery
            {
                UserId = payload.UserId
            });

            _accessTokenService.Verify(token, refreshTokenResponse.RefreshToken);

            return(await base.ExecuteAsync(controllerContext, cancellationToken));
        }
コード例 #9
0
        public EmployeeDto GetEmployee(Guid empId)
        {
            var query = new GetEmployeeQuery(empId);

            return(queryBus.Execute <GetEmployeeQuery, EmployeeDto>(query));
        }
コード例 #10
0
 public async Task <TransactionsQueryResult> GetAll(TransactionsQuery query)
 {
     return(await QueryBus.Execute <TransactionsQuery, TransactionsQueryResult>(query));
 }
コード例 #11
0
 public async Task <LocalizedValuesResponse> GetLocalization([FromUri] LocalizedValuesQuery query)
 {
     return(await QueryBus.Execute <LocalizedValuesQuery, LocalizedValuesResponse>(query));
 }
コード例 #12
0
 public async Task <TaxesResponse> GetTaxes()
 {
     return(await QueryBus.Execute <TaxesQuery, TaxesResponse>(new TaxesQuery()));
 }
コード例 #13
0
 public void TestExecuteShouldLogExecutingMessage()
 {
     _bus.Execute(_query);
     _mockLogger.Verify(p => p.LogExecuting(_query), Times.Once());
 }
コード例 #14
0
 public async Task <CustomPropertiesResponse> GetProperties()
 {
     return(await QueryBus.Execute <CustomPropertiesQuery, CustomPropertiesResponse>(new CustomPropertiesQuery()));
 }
コード例 #15
0
 public async Task <CalculatedPriceRangeResponse> Get([FromUri] GetCalculatedPriceRangeQuery query)
 {
     return(await QueryBus.Execute <GetCalculatedPriceRangeQuery, CalculatedPriceRangeResponse>(query));
 }
コード例 #16
0
 public async Task <OrdersQueryResult> GetAll(OrdersQuery query)
 {
     return(await QueryBus.Execute <OrdersQuery, OrdersQueryResult>(query));
 }
コード例 #17
0
 public async Task <BoxingsResponse> GetBoxings()
 {
     return(await QueryBus.Execute <BoxingsQuery, BoxingsResponse>(new BoxingsQuery()));
 }
コード例 #18
0
 public async Task <ShippingsResponse> GetShippings()
 {
     return(await QueryBus.Execute <ShippingsQuery, ShippingsResponse>(new ShippingsQuery()));
 }
コード例 #19
0
 public async Task <AllPricesResponse> Get()
 {
     return(await QueryBus.Execute <GetAllPricesQuery, AllPricesResponse>(new GetAllPricesQuery()));
 }
コード例 #20
0
 public async Task <EnvironmentsResponse> GetEnvironments()
 {
     return(await QueryBus.Execute <EnvironmentsQuery, EnvironmentsResponse>(new EnvironmentsQuery()));
 }
コード例 #21
0
        public async Task <AllProductsResponse> Get()
        {
            var products = await QueryBus.Execute <GetAllProductsQuery, AllProductsResponse>(new GetAllProductsQuery());

            return(products);
        }
コード例 #22
0
        public async Task <ProductsResponse> GetAll(ProductsQuery query)
        {
            var productsResponse = await QueryBus.Execute <ProductsQuery, ProductsResponse>(query);

            return(productsResponse);
        }