public virtual async Task <IHttpActionResult> UpdateRecurringOrderTemplateLineItemQuantity(UpdateRecurringOrderLineItemQuantityRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var param = new UpdateRecurringOrderTemplateLineItemQuantityParam
            {
                RecurringLineItemId = request.RecurringLineItemId,
                Quantity            = request.Quantity,
                ScopeId             = ComposerContext.Scope,
                CustomerId          = ComposerContext.CustomerId,
                CultureInfo         = ComposerContext.CultureInfo,
                BaseUrl             = RequestUtils.GetBaseUrl(Request).ToString()
            };

            var results = await RecurringOrderTemplatesViewService.UpdateRecurringOrderTemplateLineItemQuantityAsync(param).ConfigureAwait(false);

            return(Ok(results));
        }
        public virtual async Task <IHttpActionResult> GetRecurringOrderTemplateDetails(GetRecurringOrderTemplateDetailsRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (string.IsNullOrEmpty(request.RecurringOrderTemplateId))
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Guid guid;

            Guid.TryParse(request.RecurringOrderTemplateId, out guid);

            var vm = await RecurringOrderTemplatesViewService.GetRecurringOrderTemplateDetailViewModelAsync(new GetRecurringOrderTemplateDetailParam
            {
                RecurringOrderLineItemId = guid,
                Scope       = ComposerContext.Scope,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            }).ConfigureAwait(false);

            return(Ok(vm));
        }
        public virtual async Task <IHttpActionResult> UpdateRecurringOrderTemplateLineItem(UpdateRecurringOrderTemplateLineItemRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var results = await RecurringOrderTemplatesViewService.UpdateRecurringOrderTemplateLineItemAsync(new UpdateRecurringOrderTemplateLineItemParam {
                ScopeId     = ComposerContext.Scope,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),

                BillingAddressId            = request.BillingAddressId,
                LineItemId                  = request.LineItemId,
                NextOccurence               = request.NextOccurence,
                PaymentMethodId             = request.PaymentMethodId,
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                ShippingAddressId           = request.ShippingAddressId,
                ShippingMethodName          = request.ShippingMethodName,
                ShippingProviderId          = request.ShippingProviderId
            }).ConfigureAwait(false);

            return(Ok(results));
        }
        public virtual async Task <IHttpActionResult> GetRecurringOrderTemplates()
        {
            var vm = await RecurringOrderTemplatesViewService.GetRecurringOrderTemplatesViewModelAsync(new GetRecurringOrderTemplatesParam {
                Scope       = ComposerContext.Scope,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            }).ConfigureAwait(false);

            return(Ok(vm));
        }
        public virtual ActionResult RecurringSchedule()
        {
            var vm = RecurringOrderTemplatesViewService.GetRecurringOrderTemplatesViewModelAsync(new GetRecurringOrderTemplatesParam {
                Scope       = ComposerContext.Scope,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            }).Result;

            if (vm != null && vm.RecurringOrderTemplateViewModelList.Count == 0)
            {
                return(View("RecurringScheduleContainer", new { TotalQuantity = 0 }));
            }

            return(View("RecurringScheduleContainer", vm));
        }
Example #6
0
        protected virtual async Task <IPaymentMethodViewModel> IsSavedCardUsedInRecurringOrders(
            IPaymentMethodViewModel methodViewModel,
            CultureInfo cultureInfo,
            Guid customerId,
            string scope)
        {
            if (methodViewModel is SavedCreditCardPaymentMethodViewModel vm)
            {
                vm.IsUsedInRecurringOrders = await RecurringOrderTemplatesViewService.GetIsPaymentMethodUsedInRecurringOrders(new GetIsPaymentMethodUsedInRecurringOrdersRequest
                {
                    CultureInfo     = cultureInfo,
                    CustomerId      = customerId,
                    PaymentMethodId = methodViewModel.Id.ToString(),
                    ScopeId         = scope
                }).ConfigureAwait(false);

                return(vm);
            }
            return(methodViewModel);
        }
        public virtual async Task <IHttpActionResult> RemoveRecurringLineItem([FromBody] RemoveRecurringOrderTemplateLineItemRequest request)
        {
            if (string.IsNullOrWhiteSpace(request.LineItemId))
            {
                return(BadRequest("Invalid lineItemId"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var results = await RecurringOrderTemplatesViewService.RemoveRecurringOrderTemplateLineItemAsync(new RemoveRecurringOrderTemplateLineItemParam()
            {
                Culture    = ComposerContext.CultureInfo,
                ScopeId    = ComposerContext.Scope,
                LineItemId = request.LineItemId,
                CustomerId = ComposerContext.CustomerId,
                BaseUrl    = RequestUtils.GetBaseUrl(Request).ToString()
            }).ConfigureAwait(false);

            return(Ok(results));
        }
        public virtual async Task <IHttpActionResult> RemoveRecurringLineItems(RemoveRecurringOrderTemplateLineItemsRequest request)
        {
            if (request.LineItemsIds.Count == 0)
            {
                return(BadRequest("Invalid lineItemsIds"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var results = await RecurringOrderTemplatesViewService.RemoveRecurringOrderTemplatesLineItemsAsync(new RemoveRecurringOrderTemplateLineItemsParam()
            {
                Culture      = ComposerContext.CultureInfo,
                ScopeId      = ComposerContext.Scope,
                LineItemsIds = request.LineItemsIds,
                CustomerId   = ComposerContext.CustomerId,
                BaseUrl      = RequestUtils.GetBaseUrl(Request).ToString()
            });

            return(Ok(results));
        }