コード例 #1
0
        public async Task Should_Return_Default_Store()
        {
            // Arrange & Act
            var response = await _storeAppService.GetDefaultAsync();

            // Assert
            response.ShouldNotBeNull();
            response.Name.ShouldBe("My store");
        }
コード例 #2
0
ファイル: Index.cshtml.cs プロジェクト: xingx001/EShop
        public virtual async Task OnGetAsync()
        {
            //TODO: Need to handle: when StoreId is empty, and current user owns multiple store
            if (!StoreId.HasValue && CurrentUser.Id.HasValue)
            {
                var storeOwners = await _storeOwnerAppService.GetListAsync(new GetStoreOwnerListDto
                {
                    OwnerUserId = CurrentUser.Id.Value,
                });

                StoreId = storeOwners.Items.FirstOrDefault()?.StoreId;
            }

            if (!StoreId.HasValue)
            {
                var defaultStore = await _storeAppService.GetDefaultAsync();

                StoreId = defaultStore.Id;
            }

            StoreName = (await _storeAppService.GetAsync(StoreId.Value)).Name;
        }
コード例 #3
0
    public async Task OnGetAsync()
    {
        if (CurrentUser.Id is null)
        {
            return;
        }

        OrderList = await _orderAppService.GetListAsync(new GetOrderListDto
        {
            MaxResultCount = 5,
            CustomerUserId = CurrentUser.GetId(),
            Sorting        = "CreationTime DESC"
        });

        Store = await _storeAppService.GetDefaultAsync();

        CakeProduct = await _productAppService.GetByUniqueNameAsync(Store.Id, SampleDataConsts.CakeProductUniqueName);

        Order = OrderList.Items.FirstOrDefault(x => x.OrderStatus is OrderStatus.Pending && x.OrderLines.Any(ol => ol.ProductId == CakeProduct.Id));

        Wallet = (await _accountAppService.GetListAsync(new GetAccountListInput {
            UserId = CurrentUser.Id
        })).Items[0];
    }
コード例 #4
0
ファイル: StoreController.cs プロジェクト: yinchang0626/EShop
 public Task <StoreDto> GetDefaultAsync()
 {
     return(_service.GetDefaultAsync());
 }