public BrandParameterEntity Update (BrandParameterEntity entity)
		{
			try
            {
                _brandparameterRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
		public bool Delete(BrandParameterEntity entity)
		{
			try
            {
                _brandparameterRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
Example #3
0
        public HttpResponseMessage AddProductBrandParameter([FromBody]ProductBrandParameterModel productBrandParameterModel)
        {

            ProductBrandEntity pbe = _productBrandService.GetProductBrandById(productBrandParameterModel.ProductBrandId);

            var productPramater = pbe.ParameterEntities.Select(p => new { p.Parametername }).Select(pp => new
            {
                pp.Parametername
            }).ToList();
            foreach (var i in productPramater)
            {
                if (i.Parametername == productBrandParameterModel.Parametername)
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "数据已经存在,请重新编辑!"));
                }
            }

            BrandParameterEntity bpe = new BrandParameterEntity()
             {

                 Addtime = DateTime.Now,
                 Adduser = productBrandParameterModel.Adduser,
                 Updtime = DateTime.Now,
                 Upduser = productBrandParameterModel.Upduser,
                 Parametername = productBrandParameterModel.Parametername,
                 Parametervaule = productBrandParameterModel.Parametervaule,
                 ProductBrand = pbe
             };
            try
            {
                _brandParameterService.Create(bpe);
                return PageHelper.toJson(PageHelper.ReturnValue(true, "添加成功!"));
            }
            catch (Exception)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "添加失败!"));
            }
        }