Example #1
0
        /// <summary>
        /// After a new purchase order is final and saved, we need to substract the stock levels from the actual product.
        /// </summary>
        /// <param name="purchOrder"></param>
        public static void ProcessNewOrderStockLevels(SettingGroup paypalSettings, PurchaseOrderDetails purchOrder)
        {
            try
            {
                if (purchOrder != null && purchOrder.PurchasedProductList != null && purchOrder.PurchasedProductList.Count > 0)
                {
                    foreach (var PurchProd in purchOrder.PurchasedProductList)
                    {
                        Product Prod = ProductDAO.LoadByBsonId(PurchProd.Id);

                        if (Prod != null)
                        {
                            Prod.UpdateStock(PurchProd);

                            ProductDAO.Save(Prod);

                            Chimera.Core.Notifications.ProductStock.ProcessPurchasedProduct(paypalSettings, Prod);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.PurchaseOrders.ProductStock.ProcessNewOrderStockLevels()" + e.Message);
            }
        }
        public ActionResult EditSchema(string id, string settingGroupData)
        {
            try
            {
                SettingGroup SettingGroup = new SettingGroup();

                if (!string.IsNullOrWhiteSpace(id))
                {
                    SettingGroup = SettingGroupDAO.LoadSettingGroupById(id);
                }
                else if(string.IsNullOrWhiteSpace(settingGroupData))
                {
                    //add an empty setting for new setting groups
                    SettingGroup.SettingsList.Add(new Setting());
                }
                else
                {
                    SettingGroup = JsonConvert.DeserializeObject<SettingGroup>(settingGroupData);
                }

                ViewBag.SettingGroup = SettingGroup;
                ViewBag.StaticPropertyKeyList = StaticPropertyDAO.LoadAllKeyNames();
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.SettingsController.EditSchema() " + e.Message);
            }

            return View();
        }
Example #3
0
        /// <summary>
        /// Get a dictionary where the shipping method type is the key and the value is the global price when selecting that shipping method.
        /// </summary>
        /// <param name="shippingMethods"></param>
        /// <param name="paypalPurchaseSettings"></param>
        /// <returns></returns>
        public static Dictionary<string, decimal> GetGlobalShippingMethodDictionary(StaticProperty shippingMethods = null, SettingGroup paypalPurchaseSettings = null)
        {
            if (shippingMethods == null)
            {
                shippingMethods = StaticPropertyDAO.LoadByKeyName(StaticProperty.SHIPPING_METHOD_PROPERTY_KEY);
            }

            if (paypalPurchaseSettings == null)
            {
                paypalPurchaseSettings = SettingGroupDAO.LoadSettingGroupByName(SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS);
            }

            Dictionary<string, decimal> GlobalShippingMethodDictionary = new Dictionary<string, decimal>();

            if (shippingMethods != null && shippingMethods.PropertyNameValues != null && shippingMethods.PropertyNameValues.Count > 0)
            {
                foreach (var ShippValueKey in shippingMethods.PropertyNameValues)
                {
                    Setting GlobalShippingPriceSetting = paypalPurchaseSettings.SettingsList.Where(e => e.Key.Equals("GlobalBaseShippingAmt_" + ShippValueKey)).FirstOrDefault();

                    decimal GlobalShippingPrice = 0.00m;

                    if (GlobalShippingPriceSetting != null && !string.IsNullOrWhiteSpace(GlobalShippingPriceSetting.Value))
                    {
                        GlobalShippingPrice = Decimal.Parse(GlobalShippingPriceSetting.Value);
                    }

                    GlobalShippingMethodDictionary.Add(ShippValueKey, GlobalShippingPrice);
                }
            }

            return GlobalShippingMethodDictionary;
        }
Example #4
0
        /// <summary>
        /// Get the necessary paypal API auth header from our setting group.
        /// </summary>
        /// <param name="paypalSettingGroup"></param>
        /// <returns></returns>
        public static AuthHeader GetAuthHeaderFromSetting(SettingGroup paypalSettingGroup)
        {
            AuthHeader PayPalAuthHeader = new AuthHeader();

            PayPalAuthHeader.BaseApiURL = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_API);
            PayPalAuthHeader.Username = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_Username);
            PayPalAuthHeader.Password = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_Password);
            PayPalAuthHeader.Signature = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_Signature);

            return PayPalAuthHeader;
        }
Example #5
0
        /// <summary>
        /// Load a single setting group object by its unique group name
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        public static SettingGroup LoadSettingGroupByName(string groupName)
        {
            MongoCollection<SettingGroup> Collection = Execute.GetCollection<SettingGroup>(COLLECTION_NAME);

            SettingGroup SettGroup = (from e in Collection.AsQueryable<SettingGroup>() where e.GroupKey == groupName select e).FirstOrDefault();

            if (SettGroup == null)
            {
                SettGroup = new SettingGroup();
            }

            return SettGroup;
        }
        public void ProcessFile()
        {
            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.Load(FilePath);

            foreach (var Node in XmlDoc.DocumentElement.GetElementsByTagName("SettingGroup"))
            {
                XmlElement Element = (XmlElement)Node;

                SettingGroup SetGroup = new SettingGroup();

                SetGroup.GroupKey = Element.GetElementsByTagName("GroupKey")[0].InnerText;
                SetGroup.UserFriendlyName = Element.GetElementsByTagName("UserFriendlyName")[0].InnerText;
                SetGroup.Description = Element.GetElementsByTagName("Description")[0].InnerText;
                SetGroup.ParentCategory = (ParentCategoryType)Enum.Parse(typeof(ParentCategoryType), Element.GetElementsByTagName("ParentCategory")[0].InnerText);

                foreach (var ChildNode in Element.GetElementsByTagName("Setting"))
                {
                    XmlElement ChildElement = (XmlElement)ChildNode;

                    Setting Sett = new Setting();

                    Sett.Key = ChildElement.GetElementsByTagName("Key")[0].InnerText;
                    Sett.UserFriendlyName = ChildElement.GetElementsByTagName("UserFriendlyName")[0].InnerText;
                    Sett.Description = ChildElement.GetElementsByTagName("Description")[0].InnerText;
                    Sett.Value = ChildElement.GetElementsByTagName("Value")[0].InnerText;
                    Sett.EntryType = (DataEntryType) Enum.Parse(typeof(DataEntryType), ChildElement.GetElementsByTagName("EntryType")[0].InnerText);
                    Sett.DataEntryStaticPropertyKey = ChildElement.GetElementsByTagName("DataEntryStaticPropertyKey")[0].InnerText;

                    foreach (var ChildChildNode in ChildElement.GetElementsByTagName("SettingAttribute"))
                    {
                        XmlElement ChildChildElement = (XmlElement)ChildChildNode;

                        SettingAttribute SetAttr = new SettingAttribute();

                        SetAttr.Key = ChildChildElement.GetElementsByTagName("Key")[0].InnerText;
                        SetAttr.Value = ChildChildElement.GetElementsByTagName("Value")[0].InnerText;

                        Sett.SettingAttributeList.Add(SetAttr);
                    }

                    SetGroup.SettingsList.Add(Sett);
                }

                SettingGroupDAO.Save(SetGroup);
            }
        }
Example #7
0
        /// <summary>
        /// Process a purchased product after the stock level has been altered from the purchase order
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static bool ProcessPurchasedProduct(SettingGroup paypalSettings, Product product)
        {
            try
            {
                string StockLevelWarningString = paypalSettings.GetSettingVal(PayPalSettingKeys.StockLevelWarning);

                int StockLevelWarning = Int32.Parse(!string.IsNullOrWhiteSpace(StockLevelWarningString) ? StockLevelWarningString : "0");

                if (product.PurchaseSettings.StockLevel <= StockLevelWarning)
                {
                    Notification NewNotification = GenerateNewNotification(product.Name, product.Id, product.PurchaseSettings.StockLevel);

                    DashboardNotificationDAO.Save(NewNotification);
                }

                if (product.CheckoutPropertySettingsList != null && product.CheckoutPropertySettingsList.Count > 0)
                {
                    foreach (var CheckPropSetting in product.CheckoutPropertySettingsList)
                    {
                        if (CheckPropSetting.PurchaseSettings.StockLevel <= StockLevelWarning)
                        {
                            Notification NewNotification = GenerateNewNotification(product.Name, product.Id, product.PurchaseSettings.StockLevel, CheckPropSetting.CheckoutPropertySettingKeys);

                            DashboardNotificationDAO.Save(NewNotification);
                        }
                    }
                }

                return true;
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.ProductStock.ProcessPurchasedProduct()" + e.Message);
            }

            return false;
        }
Example #8
0
 /// <summary>
 /// Save or update a setting group
 /// </summary>
 /// <param name="staticProperty"></param>
 /// <returns></returns>
 public static bool Save(SettingGroup settingGroup)
 {
     return Execute.Save<SettingGroup>(COLLECTION_NAME, settingGroup);
 }