示例#1
0
        public virtual async Task <WishListSummaryViewModel> AddLineItemAsync(AddLineItemParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "param is required");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("param.Scope is required", "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("param.CultureInfo", "param");
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException("param.CartName is required", "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", "param");
            }
            if (string.IsNullOrWhiteSpace(param.ProductId))
            {
                throw new ArgumentException("param.ProductId is required", "param");
            }
            if (param.Quantity <= 0)
            {
                throw new ArgumentException("param.Quantity is required", "param");
            }
            if (string.IsNullOrWhiteSpace(param.BaseUrl))
            {
                throw new ArgumentException("param.BaseUrl is required", "param");
            }

            var wishList = await WishListRepository.AddLineItemAsync(param).ConfigureAwait(false);

            return(CreateSummaryWishListViewModel(new CreateWishListViewModelParam
            {
                WishList = wishList,
                CultureInfo = param.CultureInfo,
                BaseUrl = param.BaseUrl
            }));
        }
示例#2
0
        public virtual async Task <WishListSummaryViewModel> AddLineItemAsync(AddLineItemParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.ProductId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.ProductId)), nameof(param));
            }
            if (param.Quantity < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(param), param.Quantity, GetMessageOfZeroNegative(nameof(param.Quantity)));
            }
            if (string.IsNullOrWhiteSpace(param.BaseUrl))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.BaseUrl)), nameof(param));
            }

            var wishList = await WishListRepository.AddLineItemAsync(param).ConfigureAwait(false);

            return(CreateSummaryWishListViewModel(new CreateWishListViewModelParam
            {
                WishList = wishList,
                CultureInfo = param.CultureInfo,
                BaseUrl = param.BaseUrl
            }));
        }