Exemplo n.º 1
0
        public async Task <EntityNews> AddNewsAsync(EntityNews entityNews)
        {
            var newsRep = GetRepositoryInstance <TableNews>();

            //var newsRep = GetRepositoryInstance<TableNews>();

            //新闻已存在,直接返回
            if (newsRep.Find(x => x.Title == entityNews.Title) != null)
            {
                return(entityNews);
            }

            var model = new TableNews
            {
                NewsId       = GuidExtens.GuidTo16String(),
                Title        = entityNews.Title,
                ShortContent = entityNews.ShortContent,
                NewsContent  = entityNews.Content,
                CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                UpdateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                IsEnable     = true,
                HrefUrl      = entityNews.HrefUrl ?? "",
                Media        = entityNews.Media ?? "",
                NewsImgUrl   = "",
                NewsType     = entityNews.NewsType
            };
            await newsRep.InsertAsync(model);

            entityNews.NewsId = model.NewsId;
            return(entityNews);
        }
Exemplo n.º 2
0
        public string UploadImg(byte[] imgdata)
        {
            var saveKey      = GuidExtens.GuidTo16String() + ".jpg";
            var token        = GetToken();
            var formUploader = new FormUploader();
            var result       = formUploader.UploadData(imgdata, saveKey, token);

            return(saveKey);
        }