예제 #1
0
		public ParameterModel Get(int id)
		{
			var entity =_parameterService.GetParameterById(id);
			var model = new ParameterModel
			{
				Id = entity.Id,
//                Category = entity.Category,	
                Name = entity.Name,			
                Sort = entity.Sort,			
                AddUser = entity.AddUser,		
                AddTime = entity.AddTime,			
                UpdUser = entity.UpdUser,				
                UpdTime = entity.UpdTime,		
            };
			return model;
		}
예제 #2
0
        /// <summary>
        /// 添加参数
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
		public HttpResponseMessage Post(ParameterModel model)
		{
            if(String.IsNullOrEmpty(model.Name) || model.Id==0)
            {
               return PageHelper.toJson(PageHelper.ReturnValue(false, "数据异常!")); 
            }
            
			var entity = new ParameterEntity
			{
                Category = _categoryService.GetCategoryById(model.Id),//添加时候 这里的Id传的是分类ID         
				Name = model.Name,
				Sort = model.Sort,				
				AddTime =DateTime.Now,
                UpdTime =DateTime.Now,
			};
			if(_parameterService.Create(entity).Id > 0)
			{
                return PageHelper.toJson(PageHelper.ReturnValue(true, "添加成功!"));
			}
            return PageHelper.toJson(PageHelper.ReturnValue(false, "添加失败!")); 
		}
예제 #3
0
		public bool Put(ParameterModel model)
		{
			var entity = _parameterService.GetParameterById(model.Id);
			if(entity == null)
				return false;
//			entity.Category = model.Category;
			entity.Name = model.Name;
			entity.Sort = model.Sort;
			entity.AddUser = model.AddUser;
			entity.AddTime = model.AddTime;
			entity.UpdUser = model.UpdUser;
			entity.UpdTime = model.UpdTime;
			if(_parameterService.Update(entity) != null)
				return true;
			return false;
		}