Ejemplo n.º 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));
        }
        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);
            }
        }