Exemplo n.º 1
0
        public virtual Task <RecurringOrderLineItem> GetRecurringOrderTemplateDetails(GetRecurringOrderTemplateDetailParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.Scope == null)
            {
                throw new ArgumentNullException(nameof(param.Scope));
            }
            if (param.RecurringOrderLineItemId == null)
            {
                throw new ArgumentNullException(nameof(param.RecurringOrderLineItemId));
            }

            var getRecurringOrderLineItemsForCustomerRequest = new GetRecurringOrderLineItemRequest()
            {
                RecurringOrderLineItemId = param.RecurringOrderLineItemId,
                ScopeId = param.Scope
            };

            return(OvertureClient.SendAsync(getRecurringOrderLineItemsForCustomerRequest));
        }
Exemplo n.º 2
0
        public virtual async Task <RecurringOrderTemplateViewModel> GetRecurringOrderTemplateDetailViewModelAsync(GetRecurringOrderTemplateDetailParam param)
        {
            if (!RecurringOrdersSettings.Enabled)
            {
                return(new RecurringOrderTemplateViewModel());
            }

            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CustomerId == null)
            {
                throw new ArgumentException(nameof(param.CustomerId));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(nameof(param.CultureInfo));
            }
            if (param.RecurringOrderLineItemId == null)
            {
                throw new ArgumentException(nameof(param.RecurringOrderLineItemId));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(nameof(param.Scope));
            }
            if (string.IsNullOrWhiteSpace(param.BaseUrl))
            {
                throw new ArgumentException(nameof(param.BaseUrl));
            }

            var template = await RecurringOrderRepository.GetRecurringOrderTemplateDetails(param).ConfigureAwait(false);

            //Check if template is one of the current customer.
            if (template == null || template.CustomerId != param.CustomerId)
            {
                return(null);
            }

            var vm = await CreateTemplateDetailsViewModelAsync(new CreateRecurringOrderTemplateDetailsViewModelParam
            {
                RecurringOrderLineItem = template,
                CultureInfo            = param.CultureInfo,
                BaseUrl    = param.BaseUrl,
                CustomerId = param.CustomerId,
                ScopeId    = param.Scope
            });

            return(vm);
        }