Beispiel #1
0
        public async Task <IActionResult> GetByTypeId(long postTypeId, int pageIndex = 1, int pageDataCount = 10, bool?IsKnot = null, bool?IsEssence = null)
        {
            var postType = await TypeSvc.GetByIdAsync(postTypeId);

            if (postType == null)
            {
                return(new JsonResult(
                           new APIResult <long>()
                {
                    ErrorMsg = "帖子类型不存在"
                }
                           )
                {
                    StatusCode = 400
                });
            }
            return(new JsonResult(
                       new APIResult <ListModel <ListPostDTO> >()
            {
                Data = new ListModel <ListPostDTO>
                {
                    Datas = await PostSvc.GetPageByTypeIdAsync(postTypeId, pageIndex, pageDataCount, IsKnot, IsEssence),
                    TotalCount = await PostSvc.GetByPostTypeIdCountAsync(postTypeId, IsKnot, IsEssence)
                }
            }
                       ));
        }
Beispiel #2
0
        public async Task <IActionResult> Put(AddPostModel model)
        {
            var postType = await TypeSvc.GetByIdAsync(model.PostTypeId);

            if (postType == null)
            {
                return(new JsonResult(new APIResult <long> {
                    ErrorMsg = "帖子类型不存在"
                })
                {
                    StatusCode = 400
                });
            }

            AddPostDTO dto = new AddPostDTO();

            dto.Content = model.Content;

            dto.Title      = model.Title;
            dto.UserId     = model.UserId;
            dto.PostTypeId = model.PostTypeId;
            if (postType.Name == "分享")
            {
                dto.PostStatusId = 1;
            }
            else
            {
                dto.PostStatusId = 2;
            }
            return(new JsonResult(new APIResult <long> {
                Data = await PostSvc.AddNewAsync(dto)
            }));
        }