public HttpResponseMessage Get(ParameterSearchCondition condition)
		{      
			var model = _parameterService.GetParametersByCondition(condition).Select(c=>new
			{
				Id = c.Id,
				CategoryName = c.Category.Name,
				Name = c.Name,
				Sort = c.Sort,			
				AddTime = c.AddTime				
			}).ToList();
            return PageHelper.toJson(model);
		}
 public HttpResponseMessage Get(string CategoryId)
 {
     var condition = new ParameterSearchCondition
     {
         Category = _categoryService.GetCategoryById(Convert.ToInt32(CategoryId))
     };
     var model = _parameterService.GetParametersByCondition(condition).Select(c => new
     {
         Id = c.Id,
         CategoryName = c.Category.Name,
         Name = c.Name,
         Sort = c.Sort,
         AddTime = c.AddTime
     }).ToList();
     return PageHelper.toJson(model);
 }
		public IQueryable<ParameterEntity> GetParametersByCondition(ParameterSearchCondition condition)
		{
			var query = _parameterRepository.Table;
			try
			{
				if (condition.AddTimeBegin.HasValue)
                {
                    query = query.Where(q => q.AddTime>= condition.AddTimeBegin.Value);
                }
                if (condition.AddTimeEnd.HasValue)
                {
                    query = query.Where(q => q.AddTime < condition.AddTimeEnd.Value);
                }
				if (condition.UpdTimeBegin.HasValue)
                {
                    query = query.Where(q => q.UpdTime>= condition.UpdTimeBegin.Value);
                }
                if (condition.UpdTimeEnd.HasValue)
                {
                    query = query.Where(q => q.UpdTime < condition.UpdTimeEnd.Value);
                }
				if (condition.AddUser.HasValue)
                {
                    query = query.Where(q => q.AddUser == condition.AddUser.Value);
                }
				if (condition.UpdUser.HasValue)
                {
                    query = query.Where(q => q.UpdUser == condition.UpdUser.Value);
                }
				if (!string.IsNullOrEmpty(condition.Name))
                {
                    query = query.Where(q => q.Name.Contains(condition.Name));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Category != null)
                {
                    query = query.Where(q =>q.Category.Id==condition.Category.Id);
                }
				if(condition.OrderBy.HasValue)
				{
					switch (condition.OrderBy.Value)
                    {
						case EnumParameterSearchOrderBy.OrderById:
							query = condition.IsDescending?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id);
							break;
						case EnumParameterSearchOrderBy.OrderBySort:
							query = condition.IsDescending?query.OrderByDescending(q=>q.Sort):query.OrderBy(q=>q.Sort);
							break;
                    }
					
				}
				else
				{
					query = query.OrderBy(q=>q.Id);
				}

				if (condition.Page.HasValue && condition.PageCount.HasValue)
                {
                    query = query.Skip((condition.Page.Value - 1)*condition.PageCount.Value).Take(condition.PageCount.Value);
                }
				return query;
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return null;
			}
		}
        /// <summary>
        /// 通过分类ID获取参数及对应的参数值列表
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public HttpResponseMessage Get(int categoryId)
        {
            #region 根据参数值表查询
            //var category = _categoryService.GetCategoryById(categoryId);
            //var parvalueSecon = new ParameterValueSearchCondition
            //{
            //    OrderBy = EnumParameterValueSearchOrderBy.OrderById            
            //};
            //var value = _parameterValueService.GetParameterValuesByCondition(parvalueSecon).Where(p=>p.Parameter.Category.Id==categoryId).Select(p => new 
            //{
            //    Id = p.Id,
            //    ParameterName=p.Parameter.Name,
            //    ParameterId=p.Parameter.Id,
            //    ParameterValue = p.Value,              
            //}).ToList();
            #endregion

            #region 根据参数表查询

            var conParameter = new ParameterSearchCondition
            {
                OrderBy = EnumParameterSearchOrderBy.OrderById
            };

            var value = _parameterService.GetParametersByCondition(conParameter).Where(o => o.Category.Id == categoryId).Select(p => new
            {
                Id = p.Id,
                ParameterName = p.Name,
                ParameterValues = p.Values.Select(o => new { id = o.Id, name = o.Value }).ToList(),
                value = ""
            }).ToList();
            #endregion

            return PageHelper.toJson(value);
        }
		public int GetParameterCount (ParameterSearchCondition condition)
		{
			var query = _parameterRepository.Table;
			try
			{
				if (condition.AddTimeBegin.HasValue)
                {
                    query = query.Where(q => q.AddTime>= condition.AddTimeBegin.Value);
                }
                if (condition.AddTimeEnd.HasValue)
                {
                    query = query.Where(q => q.AddTime < condition.AddTimeEnd.Value);
                }
				if (condition.UpdTimeBegin.HasValue)
                {
                    query = query.Where(q => q.UpdTime>= condition.UpdTimeBegin.Value);
                }
                if (condition.UpdTimeEnd.HasValue)
                {
                    query = query.Where(q => q.UpdTime < condition.UpdTimeEnd.Value);
                }
				if (condition.AddUser.HasValue)
                {
                    query = query.Where(q => q.AddUser == condition.AddUser.Value);
                }
				if (condition.UpdUser.HasValue)
                {
                    query = query.Where(q => q.UpdUser == condition.UpdUser.Value);
                }
				if (!string.IsNullOrEmpty(condition.Name))
                {
                    query = query.Where(q => q.Name.Contains(condition.Name));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Categorys != null && condition.Categorys.Any())
                {
                    query = query.Where(q => condition.Categorys.Contains(q.Category));
                }
                if (condition.Category != null)
                {
                    query = query.Where(q => q.Category.Id == condition.Category.Id);
                }
				return query.Count();
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return -1;
			}
		}