Пример #1
0
        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));
        }
Пример #2
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);
        }
Пример #3
0
 public ShoppingCartModel(SettingGroup paypalPurchaseSettings, string viewType, StaticProperty shippingMethods)
 {
     PaypalPurchaseSettings  = paypalPurchaseSettings;
     ShippingMethods         = shippingMethods;
     ShoppingCartProductList = SiteContext.ShoppingCartProductList;
     ViewType = viewType;
 }
Пример #4
0
        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"));
        }
Пример #5
0
        public void CreateFromObject_CopiesPropertiesFromRegularType_IgnoresStatic()
        {
            // Arrange
            var obj = new StaticProperty();

            // Act
            var dict = new RouteValueDictionary(obj);

            // Assert
            Assert.Equal(0, dict.Count);
        }
        public void CreateFromObject_CopiesPropertiesFromRegularType_IgnoresStatic()
        {
            // Arrange
            var obj = new StaticProperty();

            // Act
            var dict = new DispatcherValueCollection(obj);

            // Assert
            Assert.IsType <DispatcherValueCollection.PropertyStorage>(dict._storage);
            Assert.Empty(dict);
        }
Пример #7
0
        public void CreateFromObject_CopiesPropertiesFromRegularType_IgnoresStatic()
        {
            // Arrange
            var obj = new StaticProperty();

            // Act
            var dict = new RouteValueDictionary(obj);

            // Assert
            Assert.NotNull(dict._propertyStorage);
            Assert.Empty(dict);
        }
Пример #8
0
        public void StaticInclude()
        {
            var prop = new StaticProperty()
            {
                HugaHuga = 999, My2 = new[] { new DameClass {
                                                  Ok = 9
                                              } }
            };

            var hoge = ZeroFormatterSerializer.Convert(prop);

            hoge.HugaHuga.Is(999);
            hoge.My2[0].Ok.Is(9);
        }
Пример #9
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 void ParseStaticPropertyPropertyTest()
        {
            JProperty      prop       = new JProperty("bundleVersionCode", 1);
            var            type       = typeof(PlayerSettings.Android);
            var            actual     = Utility.ParseStaticPropertyProperty(type, prop);
            var            expectType = typeof(PlayerSettings);
            StaticProperty expect     = new StaticProperty
            {
                PropertyInfo = type.GetProperty("bundleVersionCode"),
                Value        = 1,
            };

            Assert.AreEqual(expect.PropertyInfo, actual.PropertyInfo);
            Assert.AreEqual(expect.Value, actual.Value);
        }
        public void CreateContentTypeRequest_Test_GenerateCorrectRequest()
        {
            IteratorIdProvider      idProvider   = new IteratorIdProvider();
            ContentTypeCreationInfo creationInfo = new ContentTypeCreationInfo()
            {
                Id          = "0x10023213123123",
                Description = "Test Description",
                Group       = "Test Group",
                Name        = "Test Name",
            };
            CreateContentTypeRequest request  = new CreateContentTypeRequest(creationInfo);
            List <ActionObjectPath>  requests = request.GetRequest(idProvider);
            var actionRequests = requests.Select(r => r.Action).Where(r => r != null).ToList();
            var identities     = requests.Select(r => r.ObjectPath).Where(id => id != null).ToList();

            BaseAction          objectPath    = actionRequests[0];
            IdentityQueryAction objectIdQuery = actionRequests[1] as IdentityQueryAction;

            ObjectPathMethod createCTAction   = identities[0] as ObjectPathMethod;
            Property         contentTypesProp = identities[1] as Property;
            Property         webProp          = identities[2] as Property;
            StaticProperty   currentSiteProp  = identities[3] as StaticProperty;

            Assert.AreEqual("4", objectPath.ObjectPathId);
            Assert.AreEqual(5, objectPath.Id);

            Assert.AreEqual("4", objectIdQuery.ObjectPathId);
            Assert.AreEqual(6, objectIdQuery.Id);

            Assert.AreEqual("Add", createCTAction.Name);
            Assert.AreEqual(3, createCTAction.ParentId);
            Assert.AreEqual(4, createCTAction.Id);

            Assert.AreEqual("ContentTypes", contentTypesProp.Name);
            Assert.AreEqual(2, contentTypesProp.ParentId);
            Assert.AreEqual(3, contentTypesProp.Id);

            Assert.AreEqual("Web", webProp.Name);
            Assert.AreEqual(1, webProp.ParentId);
            Assert.AreEqual(2, webProp.Id);

            Assert.AreEqual("Current", currentSiteProp.Name);
            Assert.AreEqual("{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}", currentSiteProp.TypeId);
            Assert.AreEqual(1, currentSiteProp.Id);
        }
        public void ParseStaticPropertiesTest2()
        {
            var obj = new JObject(
                new JProperty("UnityEditor.PlayerSettings,UnityEditor", new JObject(
                                  new JProperty("keystorePass", "test-keystore"))));

            var            actual     = Utility.ParseStaticProperties(obj);
            var            expectType = typeof(PlayerSettings);
            StaticProperty expect     = new StaticProperty
            {
                PropertyInfo = expectType.GetProperty("keystorePass"),
                Value        = "test-keystore",
            };

            Assert.AreEqual(1, actual.Count);
            Assert.AreEqual(expect.PropertyInfo, actual[0].PropertyInfo);
            Assert.AreEqual(expect.Value, actual[0].Value);
        }
Пример #13
0
        protected static ReflectionProperty create(Env env,
                                                   QuercusClass cls,
                                                   StringValue propName,
                                                   bool isStatic)
        {
            Property prop;

            if (isStatic)
            {
                prop = new StaticProperty(cls, propName);
            }
            else
            {
                prop = new Property(cls, propName);
            }

            return(new ReflectionProperty(prop));
        }
        public ActionResult AddNew(string staticPropertyData)
        {
            try
            {
                StaticProperty StaticProperty = new StaticProperty();

                if (!string.IsNullOrWhiteSpace(staticPropertyData))
                {
                    StaticProperty = JsonConvert.DeserializeObject <StaticProperty>(staticPropertyData);
                }

                ViewBag.StaticProperty = StaticProperty;
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PropertiesController.AddNew() " + e.Message);
            }

            return(View());
        }
        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 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 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);
            }
        }
Пример #18
0
 public ulong VisitStaticProperty(StaticProperty t)
 {
     return(1001911);
 }
Пример #19
0
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            StaticProperty siteProperty = new StaticProperty()
            {
                Name   = "Current",
                TypeId = "{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}",
                Id     = idProvider.GetActionId()
            };

            Property web = new Property()
            {
                Id       = idProvider.GetActionId(),
                ParentId = siteProperty.Id,
                Name     = "Web"
            };

            Property contentTypes = new Property()
            {
                Id       = idProvider.GetActionId(),
                Name     = "ContentTypes",
                ParentId = web.Id
            };

            ObjectPathMethod addCtMethod = new ObjectPathMethod()
            {
                Id         = idProvider.GetActionId(),
                ParentId   = contentTypes.Id,
                Name       = "Add",
                Parameters = new MethodParameter()
                {
                    TypeId     = "{168f3091-4554-4f14-8866-b20d48e45b54}",
                    Properties = new List <Parameter>()
                    {
                        new ContentTypeCreationParameter()
                        {
                            Value = ContentTypeCreationInfo
                        }
                    }
                }
            };

            List <ActionObjectPath> result = new List <ActionObjectPath>();

            ActionObjectPath path = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = addCtMethod.Id.ToString()
                },
                ObjectPath = addCtMethod,
            };

            result.Add(path);

            ActionObjectPath identityQuery = new ActionObjectPath()
            {
                Action = new IdentityQueryAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = addCtMethod.Id.ToString()
                },
                ObjectPath = contentTypes
            };

            result.Add(identityQuery);

            ActionObjectPath webIdentity = new ActionObjectPath()
            {
                ObjectPath = web
            };

            result.Add(webIdentity);

            ActionObjectPath siteIdentity = new ActionObjectPath()
            {
                ObjectPath = siteProperty
            };

            result.Add(siteIdentity);

            return(result);
        }
Пример #20
0
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            StaticProperty siteProperty = new StaticProperty()
            {
                Name   = "Current",
                TypeId = "{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}",
                Id     = idProvider.GetActionId()
            };

            Property web = new Property()
            {
                Id       = idProvider.GetActionId(),
                ParentId = siteProperty.Id,
                Name     = "Web"
            };

            List <ActionObjectPath> result = new List <ActionObjectPath>();

            ActionObjectPath path = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = siteProperty.Id.ToString()
                },
            };

            result.Add(path);

            ActionObjectPath path2 = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = web.Id.ToString()
                },
            };

            result.Add(path2);

            ActionObjectPath identityQuery = new ActionObjectPath()
            {
                Action = new QueryAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = web.Id.ToString(),
                    SelectQuery  = new SelectQuery()
                    {
                        SelectAllProperties = false,
                        Properties          = new List <Property>()
                        {
                            new Property()
                            {
                                Name = "Title"
                            }
                        }
                    }
                },
            };

            result.Add(identityQuery);

            IdentityPath = identityQuery.Action.Id;

            ActionObjectPath webIdentity = new ActionObjectPath()
            {
                ObjectPath = web
            };

            result.Add(webIdentity);

            ActionObjectPath siteIdentity = new ActionObjectPath()
            {
                ObjectPath = siteProperty
            };

            result.Add(siteIdentity);

            return(result);
        }
Пример #21
0
        public void CreateFromObject_CopiesPropertiesFromRegularType_IgnoresStatic()
        {
            // Arrange
            var obj = new StaticProperty();

            // Act
            var dict = new RouteValueDictionary(obj);

            // Assert
            Assert.Equal(0, dict.Count);
        }
Пример #22
0
 /// <summary>
 /// Save or update a static property with new values
 /// </summary>
 /// <param name="staticProperty"></param>
 /// <returns></returns>
 public static bool Save(StaticProperty staticProperty)
 {
     return(Execute.Save <StaticProperty>(COLLECTION_NAME, staticProperty));
 }
Пример #23
0
 public ISymbolValue VisitStaticProperty(StaticProperty t)
 {
     throw new NotImplementedException();
 }
Пример #24
0
 public void VisitStaticProperty(StaticProperty p)
 {
     VisitMemberSymbol(p);
 }
Пример #25
0
 public ISymbolValue VisitStaticProperty(StaticProperty p)
 {
     return(VisitMemberSymbol(p));
 }