public ArtworkFtpSettings GetArtworkFtpSettings(int siteId)
        {
            var site = _site.GetKenticoSite(siteId);

            if (site == null)
            {
                throw new ArgumentOutOfRangeException(nameof(siteId));
            }

            bool enabled = _settings.FTPArtworkEnabled(site.Name);

            var result = new ArtworkFtpSettings()
            {
                Enabled = enabled
            };

            if (enabled)
            {
                result.Ftp = new FtpCredentials()
                {
                    Url      = _settings.FTPArtworkUrl(site.Name),
                    Login    = _settings.FTPArtworkUsername(site.Name),
                    Password = _settings.FTPArtworkPassword(site.Name)
                };
            }

            return(result);
        }
示例#2
0
        private async Task <OrderListDto> GetOrders(int pageNumber)
        {
            var siteName = _site.GetKenticoSite().Name;
            BaseResponseDto <OrderListDto> response = null;

            if (_permissions.IsAuthorizedPerResource("Kadena_Orders", "KDA_SeeAllOrders", siteName))
            {
                response = await _orderClient.GetOrders(siteName, pageNumber, _pageCapacity);
            }
            else
            {
                var customer = _kenticoUsers.GetCurrentCustomer();
                response = await _orderClient.GetOrders(customer?.Id ?? 0, pageNumber, _pageCapacity);
            }

            if (response?.Success ?? false)
            {
                return(response.Payload);
            }
            else
            {
                _logger.LogError("OrderListService - GetOrders", response?.Error?.Message);
                return(new OrderListDto());
            }
        }
示例#3
0
        public Submission GenerateNewSubmission(string orderJson = "")
        {
            int siteId     = kenticoSite.GetKenticoSite().Id;
            int userId     = kenticoUsers.GetCurrentUser().UserId;
            int customerId = kenticoUsers.GetCurrentCustomer().Id;

            var oldSubmissions = submissionProvider.GetSubmissions(siteId, userId, customerId);

            foreach (var oldSubmission in oldSubmissions)
            {
                submissionProvider.DeleteSubmission(oldSubmission.SubmissionId);
            }

            var submission = new Submission()
            {
                SubmissionId    = Guid.NewGuid(),
                AlreadyVerified = false,
                Processed       = false,
                UserId          = userId,
                CustomerId      = customerId,
                SiteId          = siteId,
                OrderJson       = orderJson
            };

            submissionProvider.SaveSubmission(submission);
            kenticoLog.LogInfo("Submission Created", "Info", $"Submission {submission.SubmissionId} was generated");
            return(submission);
        }
示例#4
0
        public async Task <MailingList> GetMailingList(Guid containerId)
        {
            var customerName = _site.GetKenticoSite().Name;

            var data = await _mailingClient.GetMailingList(containerId);

            return(_mapper.Map <MailingList>(data.Payload));
        }
示例#5
0
        public List <ResultItemPage> SearchPages(string phrase, int results)
        {
            var site = siteProvider.GetKenticoSite();
            var searchResultPages = new List <ResultItemPage>();
            var indexName         = $"KDA_PagesIndex.{site.Name}";
            var datarowsResults   = kenticoSearch.Search(phrase, indexName, "/%", results, true);

            foreach (DataRow dr in datarowsResults)
            {
                int documentId = GetDocumentId(dr[0]);

                var resultItem = new ResultItemPage()
                {
                    Id    = documentId,
                    Text  = Regex.Replace(dr[5].ToString(), @"<[^>]+>|&nbsp;", "").Trim(),
                    Title = dr[4].ToString(),
                    Url   = documents.GetDocumentUrl(documentId)
                };

                searchResultPages.Add(resultItem);
            }

            return(searchResultPages);
        }
示例#6
0
        /// <summary>
        /// Handles FE periodical request if payment processeed
        /// </summary>
        public string CreditcardSaved(string submissionId)
        {
            var submission = submissionService.GetSubmission(submissionId);

            if (submission?.AlreadyVerified ?? false)
            {
                int siteId                = kenticoSite.GetKenticoSite().Id;
                int userId                = kenticoUsers.GetCurrentUser().UserId;
                int customerId            = kenticoUsers.GetCurrentCustomer().Id;
                var submissonOwnerChecked = submission.CheckOwner(siteId, userId, customerId);

                if (submissonOwnerChecked && submission.Processed)
                {
                    var redirectUrl = submission.RedirectUrl;
                    submissionService.DeleteProcessedSubmission(submission);
                    return(redirectUrl);
                }
            }

            return(string.Empty);
        }
示例#7
0
 public string GetCustomerName()
 {
     return(_site.GetKenticoSite()?.Name);
 }
示例#8
0
        public async Task <OrderDTO> GetSubmitOrderData(SubmitOrderRequest request)
        {
            Customer customer = kenticoUsers.GetCurrentCustomer();

            var notificationEmails = request.EmailConfirmation.Union(new[] { customer.Email });

            if ((request?.DeliveryAddress?.Id ?? 0) < 0)
            {
                shoppingCart.SetShoppingCartAddress(request.DeliveryAddress);
                customer.FirstName = request.DeliveryAddress.CustomerName;
                customer.LastName  = string.Empty;
                customer.Email     = request.DeliveryAddress.Email;
                customer.Phone     = request.DeliveryAddress.Phone;
            }

            var shippingAddress = shoppingCart.GetCurrentCartShippingAddress();

            shippingAddress.Country = localization.GetCountries().FirstOrDefault(c => c.Id == shippingAddress.Country.Id);
            shippingAddress.State   = localization.GetStates().FirstOrDefault(c => c.Id == shippingAddress.State.Id);
            var billingAddress = shoppingCart.GetDefaultBillingAddress();
            var billingState   = localization.GetStates().FirstOrDefault(c => c.Id == billingAddress.StateId);
            var site           = siteProvider.GetKenticoSite();
            var paymentMethod  = shoppingCart.GetPaymentMethod(request.PaymentMethod.Id);
            var cartItems      = shoppingCart.GetShoppingCartItems();
            var currency       = siteProvider.GetSiteCurrency();
            var totals         = shoppingCart.GetShoppingCartTotals();

            totals.TotalTax = await taxService.EstimateTotalTax(shippingAddress);

            if (string.IsNullOrWhiteSpace(customer.Company))
            {
                customer.Company = settings.DefaultCustomerCompanyName;
            }

            foreach (var item in cartItems.Where(i => i.IsTemplated))
            {
                var taskId = await CallRunGeneratePdfTask(item);

                item.DesignFilePathTaskId = taskId;
            }

            var orderDto = new OrderDTO()
            {
                BillingAddress  = orderDataFactory.CreateBillingAddress(billingAddress, billingState?.StateDisplayName),
                ShippingAddress = orderDataFactory.CreateShippingAddress(shippingAddress, customer),
                Customer        = orderDataFactory.CreateCustomer(customer),
                OrderDate       = DateTime.Now,
                PaymentOption   = orderDataFactory.CreatePaymentOption(paymentMethod, request),
                Site            = new SiteDTO()
                {
                    KenticoSiteID   = site.Id,
                    KenticoSiteName = site.Name,
                    ErpCustomerId   = site.ErpCustomerId
                },
                OrderCurrency = new CurrencyDTO()
                {
                    CurrencyCode      = currency.Code,
                    KenticoCurrencyID = currency.Id
                },
                OrderStatus = new OrderStatusDTO()
                {
                    KenticoOrderStatusID = kenticoOrder.GetOrderStatusId("Pending"),
                    OrderStatusName      = "PENDING"
                },
                TotalPrice        = totals.TotalItemsPrice,
                TotalShipping     = totals.TotalShipping,
                TotalTax          = totals.TotalTax,
                Items             = cartItems.Select(item => MapCartItemTypeToOrderItemType(item)),
                NotificationsData = notificationEmails.Select(e => new NotificationInfoDto
                {
                    Email    = e,
                    Language = customer.PreferredLanguage
                })
            };

            // If only mailing list items in cart, we are not picking any delivery option
            if (!cartItems.All(i => i.IsMailingList))
            {
                var deliveryMethod = shoppingCart.GetShippingOption(request.DeliveryMethod);
                orderDto.ShippingOption = new ShippingOptionDTO()
                {
                    KenticoShippingOptionID = deliveryMethod.Id,
                    CarrierCode             = deliveryMethod.SAPName,
                    ShippingCompany         = deliveryMethod.CarrierCode,
                    ShippingService         = deliveryMethod.Service.Replace("#", "")
                };
            }

            return(orderDto);
        }