public HttpResponseMessage StaticProperty(string key, string name)
        {
            HttpContext.Current.Response.ContentType = "text/plain";
            HttpContext.Current.Response.StatusCode  = 200;

            try
            {
                if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(name))
                {
                    StaticProperty CurrentStaticProperty = StaticPropertyDAO.LoadByKeyName(key);

                    string PropertyAlreadyExists = CurrentStaticProperty.PropertyNameValues.Where(e => e.ToUpper().Equals(name.ToUpper())).FirstOrDefault();

                    if (string.IsNullOrWhiteSpace(PropertyAlreadyExists))
                    {
                        CurrentStaticProperty.PropertyNameValues.Add(name);

                        if (StaticPropertyDAO.Save(CurrentStaticProperty))
                        {
                            HttpContext.Current.Response.Write(name);
                        }
                    }
                    else
                    {
                        HttpContext.Current.Response.Write("Property Already Exists");
                    }
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Admin.UploadController.StaticProperty(): ", e);
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #2
0
        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());
        }
        /// <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);
        }
        public ActionResult Edit(string id, string productData)
        {
            try
            {
                Product Product = new Product();

                List <StaticProperty> StaticPropertyList = StaticPropertyDAO.LoadAll();

                //edit an existing product
                if (!string.IsNullOrWhiteSpace(id))
                {
                    Product = ProductDAO.LoadByBsonId(id);
                }
                //add a new product
                else if (string.IsNullOrWhiteSpace(productData))
                {
                    //add 4 empty additional images
                    Product.AdditionalImages.Add(new ProductImage());
                    Product.AdditionalImages.Add(new ProductImage());
                    Product.AdditionalImages.Add(new ProductImage());
                    Product.AdditionalImages.Add(new ProductImage());

                    StaticProperty ShippingMethods = StaticPropertyList.Where(e => e.KeyName.Equals(StaticProperty.SHIPPING_METHOD_PROPERTY_KEY)).FirstOrDefault();

                    if (ShippingMethods != null && ShippingMethods.PropertyNameValues != null && ShippingMethods.PropertyNameValues.Count > 0)
                    {
                        foreach (var ShippingMethodName in ShippingMethods.PropertyNameValues)
                        {
                            Product.PurchaseSettings.ShippingMethodList.Add(new ShippingMethodProperty(ShippingMethodName, 0));
                        }
                    }
                }
                //redirected here after attempting to save a product that failed validation
                else
                {
                    Product = JsonConvert.DeserializeObject <Product>(productData);
                }

                ViewBag.AllStaticProperties = StaticPropertyList;

                ViewBag.Product = Product;

                ViewBag.ImageList = Chimera.DataAccess.ImageDAO.LoadAll();

                return(View());
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.ProductController.Edit()" + e.Message);
            }

            AddWebUserMessageToSession(Request, String.Format("Unable to add/update products at this time."), FAILED_MESSAGE_TYPE);

            return(RedirectToAction("Index", "Dashboard"));
        }
        public ActionResult Edit(string id)
        {
            try
            {
                ViewBag.StaticProperty = StaticPropertyDAO.LoadByBsonId(id);
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PropertiesController.Edit() " + e.Message);
            }

            return(View());
        }
        public ActionResult ViewAll()
        {
            try
            {
                ViewBag.StaticPropertyList = StaticPropertyDAO.LoadAll();
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PropertiesController.ViewAll() " + e.Message);
            }

            return(View());
        }
Beispiel #7
0
        /// <summary>
        /// Get the model for the view cart view
        /// </summary>
        /// <returns></returns>
        private ShoppingCartModel GetModel()
        {
            List <SettingGroup> SettingGroupList = SettingGroupDAO.LoadByMultipleGroupNames(new List <string> {
                SettingGroupKeys.ECOMMERCE_SETTINGS, SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS
            });

            SettingGroup EcommerceSettings = SettingGroupList.Where(e => e.GroupKey.Equals(SettingGroupKeys.ECOMMERCE_SETTINGS)).FirstOrDefault();

            SettingGroup PaypalPurchaseSettings = SettingGroupList.Where(e => e.GroupKey.Equals(SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS)).FirstOrDefault();

            StaticProperty ShippingMethods = StaticPropertyDAO.LoadByKeyName(StaticProperty.SHIPPING_METHOD_PROPERTY_KEY);

            return(new ShoppingCartModel(PaypalPurchaseSettings, EcommerceSettings.GetSettingVal(ECommerceSettingKeys.ViewShoppingCartPage), ShippingMethods));
        }
        public ActionResult AddNew_Post(string staticPropertyData)
        {
            try
            {
                StaticProperty StaticProperty = JsonConvert.DeserializeObject <StaticProperty>(staticPropertyData);

                List <WebUserMessage> ErrorList = StaticProperty.Validate();

                //if passed validation
                if (ErrorList == null || ErrorList.Count == 0)
                {
                    if (StaticPropertyDAO.Save(StaticProperty))
                    {
                        AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated static property \"{0}\"", StaticProperty.KeyName), SUCCESS_MESSAGE_TYPE);
                    }
                    else
                    {
                        AddWebUserMessageToSession(Request, String.Format("Unable to saved/update static property \"{0}\" at this time", StaticProperty.KeyName), FAILED_MESSAGE_TYPE);
                    }
                }
                //failed validation
                else
                {
                    AddWebUserMessageToSession(Request, ErrorList);

                    return(RedirectToAction("AddNew", "Properties", new { staticPropertyData = staticPropertyData }));
                }

                return(RedirectToAction("Index", "Dashboard"));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PropertiesController.AddNew_Post() " + e.Message);
            }

            AddWebUserMessageToSession(Request, String.Format("Unable to save/update properties at this time."), FAILED_MESSAGE_TYPE);

            return(RedirectToAction("Index", "Dashboard"));
        }
        public ActionResult Edit_Post(string staticPropertyData)
        {
            try
            {
                StaticProperty StaticProperty = JsonConvert.DeserializeObject <StaticProperty>(staticPropertyData);

                if (StaticPropertyDAO.Save(StaticProperty))
                {
                    AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated static property \"{0}\"", StaticProperty.KeyName), SUCCESS_MESSAGE_TYPE);
                }
                else
                {
                    AddWebUserMessageToSession(Request, String.Format("Unable to saved/update static property \"{0}\" at this time", StaticProperty.KeyName), FAILED_MESSAGE_TYPE);
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PropertiesController.Edit_Post() " + e.Message);
            }

            return(RedirectToAction("Index", "Dashboard"));
        }
        public void ProcessFile()
        {
            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.Load(FilePath);

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

                StaticProperty StaticProp = new StaticProperty();

                StaticProp.KeyName = Element.GetElementsByTagName("KeyName")[0].InnerText;

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

                    StaticProp.PropertyNameValues.Add(ChildElement.InnerText);
                }

                StaticPropertyDAO.Save(StaticProp);
            }
        }
Beispiel #11
0
        public ActionResult EditValues(string id)
        {
            try
            {
                SettingGroup SettingGroup = SettingGroupDAO.LoadSettingGroupById(id);

                List <string> StaticPropertyKeys = (from e in SettingGroup.SettingsList.AsQueryable() where DataEntryTypeProperty.DataTypesRequireProperties.Contains(e.EntryType) && !string.IsNullOrWhiteSpace(e.DataEntryStaticPropertyKey) select e.DataEntryStaticPropertyKey).ToList();

                ViewBag.SettingGroup = SettingGroup;

                ViewBag.StaticPropertyList = StaticPropertyKeys != null && StaticPropertyKeys.Count > 0 ?StaticPropertyDAO.LoadByMultipleKeyNames(StaticPropertyKeys) : new List <StaticProperty>();

                ViewBag.ImageList = ImageDAO.LoadAll();
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.SettingsController.EditValues() " + e.Message);
            }

            return(View());
        }