Exemplo n.º 1
0
		public ContentEntity Update (ContentEntity entity)
		{
			try
            {
                _contentRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
Exemplo n.º 2
0
		public bool Delete(ContentEntity entity)
		{
			try
            {
                _contentRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
Exemplo n.º 3
0
 public HttpResponseMessage Create(ContentDetailModel model)
 {
     Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
     var m = reg.IsMatch(model.Title);
     if (!m)
     {
         return PageHelper.toJson(PageHelper.ReturnValue(false, "标题存在非法字符!"));
     }
     else
     {                              
             var newChannel = _channelService.GetChannelById(model.ChannelId);
             if (newChannel == null)
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(false, "请选择频道!"));
             }
             var content = new ContentEntity
             {
                 Title = model.Title,
                 TitleImg = model.TitleImg,
                 Content = model.Content,
                 Status = model.Status,
                 Channel = newChannel,
                 Adduser = _workContent.CurrentUser.Id,
                 Addtime = DateTime.Now,
                 UpdUser = _workContent.CurrentUser.Id,
                 UpdTime = DateTime.Now,
                 AdSubTitle=model.AdSubTitle
             };
             if (_contentService.Create(content) != null)
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!"));
             }
             else
             {
                 return PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!"));
             }
     }
 }