Esempio n. 1
0
 public WikiRenderer(IPluginFinder pluginFinder, IWebContext webContext)
 {
     Renderers["Comment"] = new CommentRenderer();
     Renderers["UserInfo"] = new UserInfoRenderer();
     Renderers["InternalLink"] = new InternalLinkRenderer(webContext);
     Renderers["ExternalLink"] = new ExternalLinkRenderer();
     Renderers["Text"] = FallbackRenderer = new TextRenderer();
     Renderers["Template"] = new TemplateRenderer(pluginFinder.GetPlugins<ITemplateRenderer>());
     Renderers["Heading"] = new HeadingRenderer();
     Renderers["Line"] = new LineRenderer();
     Renderers["OrderedList"] = new OrderedListRenderer();
     Renderers["UnorderedList"] = new UnorderedListRenderer();
     Renderers["Format"] = new FormatRenderer();
 }
Esempio n. 2
0
        public AdminManager(AdminSection configSection, ISecurityManager securityManager, IAdminAssemblyManager adminAssembly,
			IAuthorizationService authorizationService, IAuthenticationContextService authenticationContextService,
			IPersister persister, IVersionManager versionManager, IContentTypeManager contentTypeManager,
			Web.IWebContext webContext, ILanguageManager languageManager,
			IPluginFinder<ActionPluginGroupAttribute> actionPluginGroupFinder,
			ITypeFinder typeFinder, IEmbeddedResourceManager embeddedResourceManager)
        {
            _configSection = configSection;
            _securityManager = securityManager;
            _adminAssembly = adminAssembly;
            DeleteItemUrl = embeddedResourceManager.GetServerResourceUrl(adminAssembly.Assembly, "Zeus.Admin.Delete.aspx");
            EditItemUrl = embeddedResourceManager.GetServerResourceUrl(adminAssembly.Assembly, "Zeus.Admin.Plugins.EditItem.Default.aspx");
            NewItemUrl = embeddedResourceManager.GetServerResourceUrl(adminAssembly.Assembly, "Zeus.Admin.New.aspx");
            EnableVersioning = configSection.Versioning.Enabled;
            _authorizationService = authorizationService;
            _authenticationContextService = authenticationContextService;
            _persister = persister;
            _versionManager = versionManager;
            _contentTypeManager = contentTypeManager;
            _webContext = webContext;
            _languageManager = languageManager;

            _cachedActionPluginGroups = actionPluginGroupFinder.GetPlugins().OrderBy(g => g.SortOrder);
        }
Esempio n. 3
0
 /// <summary>
 /// Load all discount requirement rules
 /// </summary>
 /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
 /// <returns>Discount requirement rules</returns>
 public virtual IList <IDiscountRequirementRule> LoadAllDiscountRequirementRules(Customer customer = null)
 {
     return(_pluginFinder.GetPlugins <IDiscountRequirementRule>(customer: customer).ToList());
 }
 /// <summary>
 /// Load all external authentication methods
 /// </summary>
 /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
 /// <param name="storeId">Load records allowed only in a specified store; pass 0 to load all records</param>
 /// <returns>External authentication methods</returns>
 public virtual IList <IExternalAuthenticationMethod> LoadAllExternalAuthenticationMethods(Customer customer = null, int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IExternalAuthenticationMethod>(customer: customer, storeId: storeId).ToList());
 }
Esempio n. 5
0
        /// <summary>
        /// Load all promotion feeds
        /// </summary>
        /// <returns>Promotion feeds</returns>
        public virtual IList <IPromotionFeed> LoadAllPromotionFeeds()
        {
            var providers = _pluginFinder.GetPlugins <IPromotionFeed>();

            return(providers.ToList());
        }
        /// <summary>
        /// Load all discount requirement rules
        /// </summary>
        /// <returns>Discount requirement rules</returns>
        public virtual IList <IDiscount> LoadAllDiscountPlugins()
        {
            var discountPlugins = _pluginFinder.GetPlugins <IDiscount>();

            return(discountPlugins.ToList());
        }
Esempio n. 7
0
 public IList <IExternalAuthenticationMethod> LoadAllExternalAuthenticationMethods(int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IExternalAuthenticationMethod>().ToList());
 }
Esempio n. 8
0
 /// <summary>
 /// Load all payment providers
 /// </summary>
 /// <returns>Payment providers</returns>
 public virtual IList <IPaymentMethod> LoadAllPaymentMethods()
 {
     return(_pluginFinder.GetPlugins <IPaymentMethod>().ToList());
 }
Esempio n. 9
0
 /// <summary>
 /// Load all shipping rate computation methods
 /// </summary>
 /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
 /// <param name="storeId">Load records allowed only in a specified store; pass 0 to load all records</param>
 /// <returns>Shipping rate computation methods</returns>
 public virtual IList <IShippingRateComputationMethod> LoadAllShippingRateComputationMethods(Customer customer = null, int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IShippingRateComputationMethod>(customer: customer, storeId: storeId).ToList());
 }
Esempio n. 10
0
 /// <summary>
 /// Load all widget plugins
 /// </summary>
 /// <returns>widget plugins</returns>
 public virtual IList <IWidgetPlugin> LoadAllWidgetPlugins()
 {
     return(_pluginFinder.GetPlugins <IWidgetPlugin>().ToList());
 }
Esempio n. 11
0
 /// <summary>
 /// Load all payment providers
 /// </summary>
 /// <param name="storeId">Load records allows only in specified store; pass 0 to load all records</param>
 /// <returns>Payment providers</returns>
 public virtual IList <IPaymentMethod> LoadAllPaymentMethods(int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IPaymentMethod>(storeId: storeId).ToList());
 }
Esempio n. 12
0
 /// <summary>
 /// Load all widgets
 /// </summary>
 /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
 /// <param name="storeId">Load records allowed only in a specified store; pass 0 to load all records</param>
 /// <returns>Widgets</returns>
 public virtual IList <IWidgetPlugin> LoadAllWidgets(Customer customer = null, int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IWidgetPlugin>(customer: customer, storeId: storeId).ToList());
 }
Esempio n. 13
0
 /// <summary>
 /// Load all widgets
 /// </summary>
 /// <param name="storeId">Load records allowed only in a specified store; pass 0 to load all records</param>
 /// <returns>Widgets</returns>
 public IList <IWidgetPlugin> LoadAllWidgets(int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IWidgetPlugin>(storeId: storeId).ToList());
 }
Esempio n. 14
0
 private void RegisterActionsAsComponents(IEngine engine, IPluginFinder plugins)
 {
     foreach (var plugin in plugins.GetPlugins<ScheduleExecutionAttribute>())
     {
         engine.Container.AddComponent(plugin.Decorates.FullName, plugin.Decorates, plugin.Decorates);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Load all shipping rate computation methods
        /// </summary>
        /// <param name="storeId">Load records allowed only in a specified store; pass 0 to load all records</param>
        /// <returns>Shipping rate computation methods</returns>
        public virtual IList <IShippingRateComputationMethod> LoadAllShippingRateComputationMethods(string storeId = "")
        {
            var test01 = _pluginFinder.GetPlugins <IShippingRateComputationMethod>(storeId: storeId).ToList();

            return(_pluginFinder.GetPlugins <IShippingRateComputationMethod>(storeId: storeId).ToList());
        }
Esempio n. 16
0
 /// <summary>
 /// Load all external authentication methods
 /// </summary>
 /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
 /// <param name="storeId">Load records allowed only in a specified store; pass "" to load all records</param>
 /// <returns>External authentication methods</returns>
 public virtual IList <IExternalAuthenticationMethod> LoadAllExternalAuthenticationMethods(Customer customer = null, string storeId = "")
 {
     return(_pluginFinder.GetPlugins <IExternalAuthenticationMethod>().ToList());
 }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var miscPlugins = _pluginFinder.GetPlugins <GBSCheckout>(storeId: _storeContext.CurrentStore.Id).ToList();

            if (miscPlugins.Count > 0)
            {
                int                 q       = 1;
                JsonResult          result  = filterContext.Result as JsonResult;
                var                 json    = JsonConvert.SerializeObject(result.Data);
                dynamic             dresult = JsonConvert.DeserializeObject <dynamic>(json);
                NameValueCollection form    = System.Web.HttpContext.Current.Request.Form;
                NameValueCollection qs      = System.Web.HttpContext.Current.Request.QueryString;

                int productId = qs["productId"];

                if (System.Web.HttpContext.Current.Request.Form != null)
                {
                    foreach (string key in System.Web.HttpContext.Current.Request.Form.Keys)
                    {
                        if (key.Contains("EnteredQuantity"))
                        {
                            q = Int32.Parse(System.Web.HttpContext.Current.Request.Form[key]);
                        }
                    }
                }
                var product = _productService.GetProductById(productId);
                if (product == null)
                {
                    return(new NullJsonResult());
                }
                string attributesXml = ParseProductAttributes(product, form);

                bool    hasReturnAddressAttr                 = false;
                var     attributeValues                      = _productAttributeParser.ParseProductAttributeValues(attributesXml);
                decimal returnAddressPriceAdjustment         = 0;
                int     returnAddressMinimumSurchargeID      = 0;
                bool    returnAddressMinimumSurchargeApplied = true;
                if (attributeValues != null)
                {
                    foreach (var attributeValue in attributeValues)
                    {
                        hasReturnAddressAttr = (attributeValue.ProductAttributeMapping.ProductAttribute.Name == "Is Return Address" && attributeValue.Name == "Yes");
                        if (hasReturnAddressAttr)
                        {
                            returnAddressPriceAdjustment = attributeValue.PriceAdjustment;
                        }
                        if (attributeValue.ProductAttributeMapping.ProductAttribute.Name == "returnAddressMinimumSurcharge" && attributeValue.Name == "Yes")
                        {
                            returnAddressMinimumSurchargeID      = attributeValue.Id;
                            returnAddressMinimumSurchargeApplied = true;
                        }
                        else
                        {
                            returnAddressMinimumSurchargeApplied = false;
                        }
                    }
                }
                if (hasReturnAddressAttr)
                {
                    int q = 1;
                    foreach (string key in form.Keys)
                    {
                        if (key.Contains("EnteredQuantity"))
                        {
                            q = Int32.Parse(System.Web.HttpContext.Current.Request.Form[key]);
                        }
                    }


                    decimal finalPrice = decimal.Parse(dresult.price.Value, NumberStyles.Currency | NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint);

                    if (q < 100)
                    {
                        finalPrice -= returnAddressPriceAdjustment;
                        //eventually make this configurable
                        decimal adj = (5 / (decimal)q);
                        finalPrice += adj;
                    }
                    else
                    {
                        //remove returnAddressMinimumSurcharge if still on
                        if (returnAddressMinimumSurchargeApplied)
                        {
                            //   _productAttributeParser.ParseProductAttributeMappings(attributesXml);
                        }
                    }
                    dresult.price = "$" + finalPrice;
                    //put it back in the result
                    json = JsonConvert.SerializeObject(dresult);

                    var newResult = new ContentResult()
                    {
                        Content     = json,
                        ContentType = "application/json"
                    };
                    return(newResult);
                }
            }
        }
        public override decimal GetUnitPrice(Product product,
                                             Customer customer,
                                             ShoppingCartType shoppingCartType,
                                             int quantity,
                                             string attributesXml,
                                             decimal customerEnteredPrice,
                                             DateTime?rentalStartDate, DateTime?rentalEndDate,
                                             bool includeDiscounts,
                                             out decimal discountAmount,
                                             out List <DiscountForCaching> appliedDiscounts)
        {
            var miscPlugins = _pluginFinder.GetPlugins <MyPriceCalculationServicePlugin>(storeId: _storeContext.CurrentStore.Id).ToList();

            if (miscPlugins.Count > 0)
            {
                #region Amalgamation

                //AMALGAMTION is only for products that use cartons at this point
                DBManager        manager                   = new DBManager();
                ICategoryService iCategoryService          = EngineContext.Current.Resolve <ICategoryService>();
                ISpecificationAttributeService specService = EngineContext.Current.Resolve <ISpecificationAttributeService>();
                //check if amalgamation is on
                //usp check amalgamation

                IList <ProductCategory> productCategories = iCategoryService.GetProductCategoriesByProductId(product.Id);
                //string categoryIds = "";
                //for (int i = 0; i < productCategories.Count; i++)
                //{
                //    if(i < productCategories.Count && i != 0)
                //    {
                //         categoryIds += "," + productCategories[i].CategoryId.ToString();
                //    }else
                //    {
                //        categoryIds += productCategories[i].CategoryId.ToString();
                //    }
                //}

                List <int> categoryIdsList = new List <int>();
                foreach (var category in productCategories)
                {
                    categoryIdsList.Add(category.CategoryId);
                }

                //eventually current packtype will need to be an attribute passed in
                string curProductPackType = "";
                var    curItemSpecAttrs   = specService.GetProductSpecificationAttributes(product.Id);
                foreach (var spec in curItemSpecAttrs)
                {
                    if (spec.SpecificationAttributeOption.SpecificationAttribute.Name == "Pack Type")
                    {
                        curProductPackType = spec.SpecificationAttributeOption.Name;
                    }
                }

                string amalgamationDataQuery = "EXEC usp_SelectGBSAmalgamationMaster @categoryId";
                Dictionary <string, object> amalgamationDic = new Dictionary <string, object>();
                amalgamationDic.Add("@CategoryId", "");

                foreach (var cat in categoryIdsList)
                {
                    amalgamationDic["@CategoryId"] = cat;
                    DataView amalgamationDataView = manager.GetParameterizedDataView(amalgamationDataQuery, amalgamationDic);

                    if (amalgamationDataView != null && amalgamationDataView.Count > 0 && curProductPackType == "Carton")
                    {
                        ICollection <ShoppingCartItem> cartItemList = customer.ShoppingCartItems;
                        if (cartItemList != null)
                        {
                            List <int> amalgamationMasterCategoryList = new List <int>(); //used if multiple master category id are returned
                            int        masterCategoryId;                                  //used to get featured product id
                            int        amalgamationGroupId;                               //group that holds all the associated category ids
                            int        bestPriceProductId;
                            int        qty = 0;

                            for (int i = 0; i < amalgamationDataView.Count; i++)
                            {
                                //add all return master Ids
                                amalgamationMasterCategoryList.Add(Int32.Parse(amalgamationDataView[i]["masterCategoryId"].ToString()));
                            }

                            int[] masterIdProductIdGroupId = GetRealMasterId(amalgamationMasterCategoryList);
                            masterCategoryId    = masterIdProductIdGroupId[0];
                            bestPriceProductId  = masterIdProductIdGroupId[1];
                            amalgamationGroupId = masterIdProductIdGroupId[2];

                            List <int> categoryGroupMembersIds = GetCategoryGroupIds(amalgamationGroupId);

                            Dictionary <int, int> qtyEachDic = new Dictionary <int, int>();

                            //remove items that don't use the carton packtype
                            List <ShoppingCartItem> AmalgamationList = new List <ShoppingCartItem>();
                            foreach (var item in cartItemList)
                            {
                                var specAttrs = specService.GetProductSpecificationAttributes(item.ProductId);
                                foreach (var spec in specAttrs)
                                {
                                    string type = "";
                                    if (spec.SpecificationAttributeOption.SpecificationAttribute.Name == "Pack Type")
                                    {
                                        type = spec.SpecificationAttributeOption.Name;
                                        if (type == "Carton")
                                        {
                                            //cartItemList.Remove(item);
                                            AmalgamationList.Add(item);
                                        }
                                    }
                                }
                            }

                            for (int i = 0; i < categoryGroupMembersIds.Count; i++)
                            {
                                foreach (ShoppingCartItem item in AmalgamationList)
                                {
                                    IList <ProductCategory> cartProductCategories = iCategoryService.GetProductCategoriesByProductId(item.ProductId);

                                    foreach (ProductCategory cartCategory in cartProductCategories)
                                    {
                                        if (cartCategory.CategoryId == categoryGroupMembersIds[i])
                                        {
                                            if (!qtyEachDic.ContainsKey(item.Id))
                                            {
                                                qtyEachDic.Add(item.Id, item.Quantity);
                                            }
                                        }
                                    }
                                }
                            }

                            foreach (KeyValuePair <int, int> pair in qtyEachDic)
                            {
                                qty += pair.Value;
                            }

                            //qty = 20;

                            product  = _productService.GetProductById(bestPriceProductId);
                            quantity = qty;
                        }

                        break;
                    }
                }



                //get quantity by finding the number of items that belong to the same alamgamation category
                //change quantity on get unit price to get proper per unit price.
                //if (product.Id == 4430)
                //{
                //    quantity = 31;
                //}

                #endregion Amalgamation

                decimal finalPrice = base.GetUnitPrice(product, customer, shoppingCartType, quantity, attributesXml, customerEnteredPrice, rentalStartDate, rentalEndDate, includeDiscounts, out discountAmount, out appliedDiscounts);
                //eventually make this a configurable rules plugin
                bool    hasReturnAddressAttr         = false;
                var     attributeValues              = _productAttributeParser.ParseProductAttributeValues(attributesXml);
                decimal returnAddressPriceAdjustment = 0;
                //int returnAddressMinimumSurchargeID = 0;
                //bool returnAddressMinimumSurchargeApplied = true;
                if (attributeValues != null)
                {
                    foreach (var attributeValue in attributeValues)
                    {
                        if (attributeValue.ProductAttributeMapping.ProductAttribute.Name == "Add Return Address" && attributeValue.Name == "Yes")
                        {
                            hasReturnAddressAttr         = true;
                            returnAddressPriceAdjustment = attributeValue.PriceAdjustment;
                        }

                        //if (attributeValue.ProductAttributeMapping.ProductAttribute.Name == "returnAddressMinimumSurcharge" && attributeValue.Name == "Yes")
                        //{
                        //    returnAddressMinimumSurchargeID = attributeValue.Id;
                        //    returnAddressMinimumSurchargeApplied = true;
                        //}else
                        //{
                        //    returnAddressMinimumSurchargeApplied = false;
                        //}
                    }
                }
                if (hasReturnAddressAttr)
                {
                    int q = quantity;
                    //quanitity is being set to 1 for product details and Customers Canvas Editor in NOP Core, so have to get it from th Form
                    if (_contextAccessor.HttpContext.Request.Form != null)
                    {
                        foreach (string key in _contextAccessor.HttpContext.Request.Form.Keys)
                        {
                            if (key.Contains("EnteredQuantity"))
                            {
                                q = Int32.Parse(_contextAccessor.HttpContext.Request.Form[key]);
                            }
                        }
                    }

                    if (q < 100)    //quantity is being passed from CC correctly?
                    {
                        finalPrice -= returnAddressPriceAdjustment;
                        //eventually make this configurable
                        decimal adj = (5 / (decimal)q);
                        finalPrice += adj;
                    }
                    else
                    {
                        ////remove returnAddressMinimumSurcharge if still on
                        //if (returnAddressMinimumSurchargeApplied)
                        //{
                        //    //   _productAttributeParser.ParseProductAttributeMappings(attributesXml);
                        //}
                    }
                }
                return(finalPrice);
            }

            //if we get here it is because the plugin isn't installed and the base class is called
            return(base.GetUnitPrice(product, customer, shoppingCartType, quantity, attributesXml, customerEnteredPrice, rentalStartDate, rentalEndDate, includeDiscounts, out discountAmount, out appliedDiscounts));
        }
Esempio n. 19
0
 /// <summary>
 /// Load all tax providers
 /// </summary>
 /// <returns>Tax providers</returns>
 public virtual IList <ITaxProvider> LoadAllTaxProviders()
 {
     return(_pluginFinder.GetPlugins <ITaxProvider>().ToList());
 }
Esempio n. 20
0
 private IEnumerable<ScheduledAction> InstantiateActions(IPluginFinder plugins)
 {
     foreach (ScheduleExecutionAttribute attr in plugins.GetPlugins<ScheduleExecutionAttribute>())
     {
         ScheduledAction action = Activator.CreateInstance(attr.Decorates) as ScheduledAction;
         action.Interval = CalculateInterval(attr.Interval, attr.Unit);
         action.Repeat = attr.Repeat;
         yield return action;
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Load all hooks
 /// </summary>
 /// <returns></returns>
 public virtual IList <IHookPlugin> LoadAllHooks()
 {
     return(_pluginFinder.GetPlugins <IHookPlugin>().ToList());
 }
 /// <summary>
 /// Load all external authentication methods
 /// </summary>
 /// <returns>External authentication methods</returns>
 public virtual IList <IExternalAuthenticationMethod> LoadAllExternalAuthenticationMethods()
 {
     return(_pluginFinder.GetPlugins <IExternalAuthenticationMethod>().ToList());
 }
Esempio n. 23
0
 /// <summary>
 /// Load all tax providers
 /// </summary>
 /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
 /// <returns>Tax providers</returns>
 public virtual IList <ITaxProvider> LoadAllTaxProviders(Customer customer = null)
 {
     return(_pluginFinder.GetPlugins <ITaxProvider>(customer: customer).ToList());
 }
Esempio n. 24
0
 /// <summary>Gets edit mode plugins found in the environment sorted and filtered by the given user.</summary>
 /// <typeparam name="T">The type of plugin to get.</typeparam>
 /// <param name="user">The user that should be authorized for the plugin.</param>
 /// <param name="item">The item to filter item-specific permissions for.</param>
 /// <returns>An enumeration of plugins.</returns>
 public virtual IEnumerable <T> GetPlugins <T>(IPrincipal user)
     where T : AdministrativePluginAttribute
 {
     return(pluginFinder.GetPlugins <T>(user));
 }
Esempio n. 25
0
 /// <summary>
 /// Load all shipping rate computation methods
 /// </summary>
 /// <returns>Shipping rate computation methods</returns>
 public virtual IList <IShippingRateComputationMethod> LoadAllShippingRateComputationMethods()
 {
     return(_pluginFinder.GetPlugins <IShippingRateComputationMethod>().ToList());
 }
Esempio n. 26
0
        /// <summary>
        /// Prepare the customer order list model
        /// </summary>
        /// <returns>Customer order list model</returns>
        public virtual CustomerOrderListModel PrepareCustomerOrderListModel(string status, int?page, int?pageSize)
        {
            if (page == 0)
            {
                page = null;
            }

            List <int> statusList = new List <int>();

            if (!string.IsNullOrEmpty(status))
            {
                if (status == ((int)OrderStatus.Cancelled).ToString())
                {
                    statusList.Add((int)OrderStatus.Cancelled);
                }

                if (status == ((int)OrderStatus.Pending).ToString())
                {
                    statusList.Add((int)OrderStatus.Pending);
                    statusList.Add((int)OrderStatus.Processing);
                }
            }

            var model  = new CustomerOrderListModel();
            var orders = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id,
                                                    customerId: _workContext.CurrentCustomer.Id, osIds: statusList); //pageIndex: --page ?? 0, pageSize: 5,

            List <CustomerOrderListModel.OrderDetailsModel> allOrders = new List <CustomerOrderListModel.OrderDetailsModel>();

            foreach (var order in orders)
            {
                var orderModel = new CustomerOrderListModel.OrderDetailsModel
                {
                    Id                     = order.Id,
                    CreatedOn              = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
                    OrderStatusEnum        = order.OrderStatus,
                    OrderStatus            = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                    PaymentStatus          = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext),
                    ShippingStatus         = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext),
                    IsReturnRequestAllowed = _orderProcessingService.IsReturnRequestAllowed(order),
                    CustomOrderNumber      = order.CustomOrderNumber
                };
                var orderTotalInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderTotal, order.CurrencyRate);
                orderModel.OrderTotal = _priceFormatter.FormatPrice(orderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false, _workContext.WorkingLanguage);

                allOrders.Add(orderModel);
            }

            List <CustomerOrderListModel.OrderDetailsModel> legacyOrders = null;
            var miscPlugins = _pluginFinder.GetPlugins <MyOrderServicePlugin>(storeId: EngineContext.Current.Resolve <IStoreContext>().CurrentStore.Id).ToList();

            if (miscPlugins.Count > 0 && _gbsOrderSettings.LegacyOrdersInOrderHistory)
            {
                legacyOrders = new Orders.OrderExtensions().getLegacyOrders();
                if (!string.IsNullOrEmpty(status))
                {
                    legacyOrders = legacyOrders.Where(x => statusList.Contains((int)x.OrderStatusEnum)).ToList();
                }

                if (legacyOrders != null && legacyOrders.Count() > 0)
                {
                    allOrders.AddRange(legacyOrders);
                }
                allOrders.Sort((x, y) => y.CreatedOn.CompareTo(x.CreatedOn));
            }

            var ordersPaging = new PagedList <CustomerOrderListModel.OrderDetailsModel>(allOrders, pageIndex: --page ?? 0, pageSize: pageSize ?? 5);

            model.Orders = ordersPaging.ToList();

            // do paging on orders

            var recurringPayments = _orderService.SearchRecurringPayments(_storeContext.CurrentStore.Id,
                                                                          _workContext.CurrentCustomer.Id);

            foreach (var recurringPayment in recurringPayments)
            {
                var recurringPaymentModel = new CustomerOrderListModel.RecurringOrderModel
                {
                    Id                  = recurringPayment.Id,
                    StartDate           = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(),
                    CycleInfo           = string.Format("{0} {1}", recurringPayment.CycleLength, recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext)),
                    NextPayment         = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "",
                    TotalCycles         = recurringPayment.TotalCycles,
                    CyclesRemaining     = recurringPayment.CyclesRemaining,
                    InitialOrderId      = recurringPayment.InitialOrder.Id,
                    InitialOrderNumber  = recurringPayment.InitialOrder.CustomOrderNumber,
                    CanCancel           = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment),
                    CanRetryLastPayment = _orderProcessingService.CanRetryLastRecurringPayment(_workContext.CurrentCustomer, recurringPayment)
                };

                model.RecurringOrders.Add(recurringPaymentModel);
            }

            model.CustomProperties["PagerModel"] = new PagerModel
            {
                PageSize         = ordersPaging.PageSize,
                TotalRecords     = ordersPaging.TotalCount,
                PageIndex        = ordersPaging.PageIndex,
                ShowTotalSummary = true,
                RouteActionName  = "CustomerOrders",
                UseRouteLinks    = true,
                RouteValues      = new OrderRouteValues {
                    page = page ?? 0, status = status, pageSize = pageSize
                }
            };

            if (model.Orders.Any())
            {
                model.Orders.FirstOrDefault().CustomProperties["PagerModel"] = new PagerModel
                {
                    PageSize         = ordersPaging.PageSize,
                    TotalRecords     = ordersPaging.TotalCount,
                    PageIndex        = ordersPaging.PageIndex,
                    ShowTotalSummary = true,
                    RouteActionName  = "CustomerOrders",
                    UseRouteLinks    = true,
                    RouteValues      = new OrderRouteValues {
                        page = page ?? 0, status = status, pageSize = pageSize
                    }
                };
            }

            return(model);
        }
Esempio n. 27
0
 public ContentPropertyManager(IPluginFinder<BasePropertyDataTypeAttribute> pluginFinder)
 {
     _propertyDataTypes = pluginFinder.GetPlugins().OrderBy(p => p.SortOrder);
 }
Esempio n. 28
0
        public IList <IExchangeRateProvider> LoadAllExchangeRateProviders()
        {
            var exchangeRateProviders = _pluginFinder.GetPlugins <IExchangeRateProvider>();

            return(exchangeRateProviders.OrderBy(m => m.PluginDescriptor).ToList());
        }
Esempio n. 29
0
        /// <summary>
        /// Load all discount requirement rules
        /// </summary>
        /// <returns>Discount requirement rules</returns>
        public virtual IList <IDiscountRequirementRule> LoadAllDiscountRequirementRules()
        {
            var rules = _pluginFinder.GetPlugins <IDiscountRequirementRule>();

            return(rules.ToList());
        }
Esempio n. 30
0
 /// <summary>
 /// Load all widgets
 /// </summary>
 /// <param name="user">Load records allowed only to a specified user; pass null to ignore ACL permissions</param>
 /// <returns>Widgets</returns>
 public virtual IList <IWidgetPlugin> LoadAllWidgets(User user = null)
 {
     return(_pluginFinder.GetPlugins <IWidgetPlugin>(user: user).ToList());
 }
Esempio n. 31
0
 /// <summary>
 /// Load all shipping rate computation methods
 /// </summary>
 /// <param name="storeId">Load records allowed only in a specified store; pass 0 to load all records</param>
 /// <returns>Shipping rate computation methods</returns>
 public virtual IList <IShippingRateComputationMethod> LoadAllShippingRateComputationMethods(int storeId = 0)
 {
     return(_pluginFinder.GetPlugins <IShippingRateComputationMethod>(storeId: storeId).ToList());
 }
Esempio n. 32
0
        /// <summary>
        /// Load all exchange rate providers
        /// </summary>
        /// <param name="customer">Load records allowed only to a specified customer; pass null to ignore ACL permissions</param>
        /// <returns>Exchange rate providers</returns>
        public virtual IList <IExchangeRateProvider> LoadAllExchangeRateProviders(Customer customer = null)
        {
            var exchangeRateProviders = _pluginFinder.GetPlugins <IExchangeRateProvider>(customer: customer);

            return(exchangeRateProviders.OrderBy(tp => tp.PluginDescriptor).ToList());
        }
Esempio n. 33
0
 /// <summary>
 /// Load all widgets
 /// </summary>
 /// <param name="storeId">Load records allowed only in a specified store; pass "" to load all records</param>
 /// <returns>Widgets</returns>
 public virtual IList <IWidgetPlugin> LoadAllWidgets(string storeId = "")
 {
     return(_pluginFinder.GetPlugins <IWidgetPlugin>(storeId: storeId).ToList());
 }
Esempio n. 34
0
 /// <summary>
 /// Load all external authentication methods
 /// </summary>
 /// <param name="user">Load records allowed only to a specified user; pass null to ignore ACL permissions</param>
 /// <returns>External authentication methods</returns>
 public virtual IList <IExternalAuthenticationMethod> LoadAllExternalAuthenticationMethods(User user = null)
 {
     return(_pluginFinder.GetPlugins <IExternalAuthenticationMethod>(user: user).ToList());
 }