示例#1
0
		public bool Delete(TagEntity entity)
		{
			try
            {
                _tagRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
示例#2
0
		public TagEntity Update (TagEntity entity)
		{
			try
            {
                _tagRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
示例#3
0
 public HttpResponseMessage Create(TagModel tag)
 {
     Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
     var m = reg.IsMatch(tag.Tag);
     if (!m)
     {
         return PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!"));
     }
                 
         var tagCon = new TagSearchCondition
         {
             Tag = tag.Tag
         };
         var tagCount = _tagService.GetTagCount(tagCon);
         if (tagCount > 0)
         {
             return PageHelper.toJson(PageHelper.ReturnValue(false, "数据已存在"));
         }
         else
         {
             var tagModel = new TagEntity
             {
                 Tag = tag.Tag,
                 Adduser = _workContext.CurrentUser.Id,
                 Addtime = DateTime.Now,
                 UpdUser = _workContext.CurrentUser.Id,
                 UpdTime = DateTime.Now
             };
             if (_tagService.Create(tagModel) != null)
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!"));
             }
             else
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!"));
             }
         }
     }