Exemplo n.º 1
0
        /// <summary>
        /// 新增好文
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <ActionOutput <string> > InsertNiceArticle(NiceArticleDto dto)
        {
            using (var uow = UnitOfWorkManager.Begin())
            {
                var output = new ActionOutput <string>();

                var niceArticle = new Core.Domain.NiceArticle.NiceArticle
                {
                    Title      = dto.Title,
                    Author     = dto.Author,
                    Source     = dto.Source,
                    Url        = dto.Url,
                    CategoryId = dto.CategoryId,
                    Time       = dto.Time
                };

                var result = await _niceArticleRepository.InsertAsync(niceArticle);

                await uow.CompleteAsync();

                if (result.IsNull())
                {
                    output.AddError("新增标签出错了~~~");
                }
                else
                {
                    output.Result = "success";
                }

                return(output);
            }
        }
Exemplo n.º 2
0
        public async Task <Response <string> > InsertNiceArticle([FromBody] NiceArticleDto dto)
        {
            var response = new Response <string>();

            var result = await _niceArticleService.InsertNiceArticle(dto);

            if (!result.Success)
            {
                response.SetMessage(ResponseStatusCode.Error, result.GetErrorMessage());
            }
            else
            {
                response.Result = result.Result;
            }
            return(response);
        }