Пример #1
0
 public static int Add(ArticleInfo entity)
 {
     entity.Id = dal.Add(entity);
     UploadBLL.UpdateUpload(TableID, 0, entity.Id, Cookies.Admin.GetRandomNumber(false));
     CacheHelper.Remove(cacheKey);
     return(entity.Id);
 }
        public async Task <ArticleViewModel> Create(CreateArticleViewModel model, string hashUser)
        {
            var user = await _user.GetByHash(hashUser);

            var data = new Article();

            data.IdUser        = user.Id;
            data.PublishedDate = DateTime.Now;
            data.Text          = model.Text;
            data.Title         = model.Title;

            return(_mapper.Map <ArticleViewModel>(await _article.Add(data)));
        }
Пример #3
0
        public object ArticleAdd()
        {
            var value = Request.Form.FirstOrDefault(c => c.Key == "DtoArticleParams").Value;

            if (String.IsNullOrEmpty(value))
            {
                return("");
            }

            var article = Newtonsoft.Json.JsonConvert.DeserializeObject <DtoArticleParams> (value);
            var file    = Request.Form.Files[0];

            if (file == null)
            {
                return("");
            }

            using (var target = new MemoryStream()) {
                file.CopyToAsync(target);
                article.Img = target.ToArray();
            }

            return(_Article.Add(article));
        }
Пример #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(TravelAgent.Model.Article model)
 {
     dal.Add(model);
 }