Example #1
0
		public ChannelEntity Update (ChannelEntity entity)
		{
			try
            {
                _channelRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
Example #2
0
		public bool Delete(ChannelEntity entity)
		{
			try
            {
                _channelRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
 public HttpResponseMessage Create(ChannelModel model)
 {
     Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
     var m = reg.IsMatch(model.Name);
     if (!m)
     {
         return PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!"));
     }
     else
     {
         var channelCon = new ChannelSearchCondition
         {
             Name = model.Name               
         };
         var totalCount = _channelService.GetChannelCount(channelCon);
         if (totalCount > 0)
         {
             return PageHelper.toJson(PageHelper.ReturnValue(false, "数据已存在!"));
         }
         else
         {
             var newParent = model.ParentId == 0 ? null : _channelService.GetChannelById(model.ParentId);
             var channel = new ChannelEntity
             {
                 Name = model.Name,
                 Status = model.Status,
                 Parent = newParent,
                 Adduser = _workContent.CurrentUser.Id,
                 Addtime = DateTime.Now,
                 UpdUser = _workContent.CurrentUser.Id,
                 UpdTime = DateTime.Now
             };
             if (_channelService.Create(channel) != null)
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!"));
             }
             else
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!"));
             }
         }
     }
 }