Esempio n. 1
0
        public string resultReturn(preg_guides data)
        {
            string result = "{";

            for (int i = 0; i < data.GetType().GetProperties().ToList().Count(); i++)
            {
                string propertyName  = data.GetType().GetProperties().ToList()[i].Name;
                var    propertyValue = data.GetType().GetProperty(propertyName).GetValue(data, null);
                if (propertyName == "preg_guides_type")
                {
                }
                else if (propertyName == "preg_page")
                {
                }
                else
                {
                    result += @"""" + propertyName + @""":""" + propertyValue.ToString() + @""",";
                }
            }
            result += "}";
            return(result);
        }
Esempio n. 2
0
        public IQueryable <preg_guides> GetItemsByParams(preg_guides data)
        {
            IQueryable <preg_guides> result = connect.preg_guides;

            for (int i = 0; i < data.GetType().GetProperties().ToList().Count(); i++)
            {
                string propertyName  = data.GetType().GetProperties().ToList()[i].Name;
                var    propertyValue = data.GetType().GetProperty(propertyName).GetValue(data, null);
                if (propertyName == "id" && (int)(propertyValue) != 0)
                {
                    result = result.Where(c => c.id == (int)(propertyValue));
                }
                else if (propertyName == "page_id" && propertyValue != null)
                {
                    result = result.Where(c => c.page_id == (int)(propertyValue));
                }
                else if (propertyName == "guides_type_id" && propertyValue != null)
                {
                    result = result.Where(c => c.guides_type_id == (int)(propertyValue));
                }
            }
            return(result);
        }