示例#1
0
        public ActionResult SharedWishListTitle(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View("SharedWishListHeaderBlade"));
            }

            var param = SharedWishListTokenizer.DecryptToken(id);

            if (param == null)
            {
                return(HttpNotFound());
            }

            var vm = CustomerViewService.GetAccountHeaderViewModelAsync(new GetAccountHeaderViewModelParam
            {
                Scope       = param.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = param.CustomerId
            }).Result;

            if (vm == null)
            {
                return(HttpNotFound());
            }

            return(View("SharedWishListHeaderContainer", vm));
        }
示例#2
0
        public void WHEN_token_format_is_wrong_SHOULD_return_null()
        {
            //Arrange
            var token = GetRandom.String(17);

            //Act
            var tokenDto = SharedWishListTokenizer.DecryptToken(token);

            //Assert
            tokenDto.Should().BeNull("token is in the wrong format");
        }
示例#3
0
        public void WHEN_token_is_invalid_SHOULD_throw_ArgumentException(string token)
        {
            //Arrange

            //Act
            var ex = Assert.Throws <ArgumentException>(() => SharedWishListTokenizer.DecryptToken(token));

            //Assert
            ex.Should().NotBeNull();
            ex.ParamName.Should().NotBeNullOrWhiteSpace();
        }
示例#4
0
        public void WHEN_token_is_valid_SHOULD_return_dto(string scope)
        {
            //Arrange
            var param = new SharedWishListToken
            {
                CustomerId = Guid.NewGuid(),
                Scope      = scope
            };

            var token = SharedWishListTokenizer.GenerateToken(param);

            //Act
            var dto = SharedWishListTokenizer.DecryptToken(token);

            //Assert
            dto.Should().NotBeNull();
            dto.CustomerId.Should().Be(param.CustomerId);
            dto.Scope.Should().Be(param.Scope);
        }
示例#5
0
        public ActionResult SharedWishList(string id, XhtmlDocument emptyWishListContent)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(HttpNotFound());
            }

            var param = SharedWishListTokenizer.DecryptToken(id);

            if (param == null)
            {
                return(HttpNotFound());
            }

            var customerStatus = CustomerViewService.GetAccountStatusViewModelAsync(new GetAccountStatusViewModelParam
            {
                CultureInfo = ComposerContext.CultureInfo,
                Scope       = param.Scope,
                CustomerId  = param.CustomerId
            }).Result;

            if (customerStatus == null || customerStatus.Status == AccountStatusEnum.Inactive)
            {
                return(HttpNotFound());
            }

            var vm = WishLisViewService.GetWishListViewModelAsync(new GetCartParam
            {
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                CultureInfo = ComposerContext.CultureInfo,
                CartName    = CartConfiguration.WishlistCartName,
                Scope       = param.Scope,
                CustomerId  = param.CustomerId
            }).Result;

            if (vm != null && vm.TotalQuantity == 0 && emptyWishListContent != null)
            {
                return(View("SharedWishListContainer", new { TotalQuantity = 0, EmptyContent = emptyWishListContent.Body }));
            }

            return(View("SharedWishListContainer", vm));
        }