Ejemplo n.º 1
0
        protected override GetKnowledgeDetailRD ProcessRequest(DTO.Base.APIRequest <GetKnowledgeDetailRP> pRequest)
        {
            GetKnowledgeDetailRD rd = new GetKnowledgeDetailRD();
            var bll    = new KnowledgeBLL(CurrentUserInfo);
            var entity = bll.GetByID(pRequest.Parameters.ID);

            if (entity == null)
            {
                throw new APIException(string.Format("未找到ID:{0}的文章", pRequest.Parameters.ID))
                      {
                          ErrorCode = 340
                      };
            }
            var info = new KnowledgeInfo
            {
                Author        = entity.Author,
                ClickCount    = entity.ClickCount,
                Content       = entity.Content,
                Description   = entity.Remark,
                EvaluateCount = entity.EvaluateCount,
                ID            = entity.KnowIedgeId,
                ImageUrl      = entity.ImageUrl,
                KeepCount     = entity.KeepCount,
                PraiseCount   = entity.PraiseCount,
                ShareCount    = entity.ShareCount,
                Title         = entity.Title,
                TreadCount    = entity.TreadCount
            };

            rd.KnowledgeInfo = info;
            return(rd);
        }
Ejemplo n.º 2
0
        protected override KeepKnowledgeRD ProcessRequest(DTO.Base.APIRequest <KeepKnowledgeRP> pRequest)
        {
            KeepKnowledgeRD rd   = new KeepKnowledgeRD();
            var             para = pRequest.Parameters;

            #region 文章的收藏数据+1
            var bll    = new KnowledgeBLL(CurrentUserInfo);
            var entity = bll.GetByID(para.ID);
            entity.KeepCount++;
            bll.Update(entity);
            #endregion

            #region 往文章的收藏表插入一条记录。
            var keepbll    = new KnowledgeKeepBLL(CurrentUserInfo);
            var keepEntity = new KnowledgeKeepEntity()
            {
                VipId       = CurrentUserInfo.UserID,
                KnowIedgeId = para.ID
            };
            var temp = keepbll.QueryByEntity(keepEntity, null);
            if (temp.Length == 0)
            {
                keepEntity.KnowledgeKeepId = Guid.NewGuid();
                keepbll.Create(keepEntity);
            }
            #endregion
            return(rd);
        }
Ejemplo n.º 3
0
        protected override TreadKnowledgeRD ProcessRequest(DTO.Base.APIRequest <TreadKnowledgeRP> pRequest)
        {
            TreadKnowledgeRD rd = new TreadKnowledgeRD();
            var para            = pRequest.Parameters;

            #region 文章的踩数+1

            var bll    = new KnowledgeBLL(CurrentUserInfo);
            var entity = bll.GetByID(para.ID);
            entity.TreadCount++;
            bll.Update(entity);

            #endregion

            #region 往文章的踩表插入一条记录
            var treadbll    = new KnowledgeTreadBLL(CurrentUserInfo);
            var treadEntity = new KnowledgeTreadEntity()
            {
                VipId       = CurrentUserInfo.UserID,
                KnowIedgeId = para.ID
            };
            var temp = treadbll.QueryByEntity(treadEntity, null);
            if (temp.Length == 0)
            {
                treadEntity.TreadId = Guid.NewGuid();
                treadbll.Create(treadEntity);
            }

            #endregion
            return(rd);
        }
Ejemplo n.º 4
0
        protected override PraiseKnowledgeRD ProcessRequest(DTO.Base.APIRequest <PraiseKnowledgeRP> pRequest)
        {
            PraiseKnowledgeRD rd = new PraiseKnowledgeRD();
            var para             = pRequest.Parameters;

            #region 更新文章 赞的数量
            var bll    = new KnowledgeBLL(CurrentUserInfo);
            var entity = bll.GetByID(para.ID);
            entity.PraiseCount++;
            bll.Update(entity);
            #endregion

            #region 往文章赞表中插入一条记录
            var praisebll    = new KnowledgePraiseBLL(CurrentUserInfo);
            var praiseEntity = new KnowledgePraiseEntity()
            {
                PraiseId    = Guid.NewGuid(),
                VipId       = CurrentUserInfo.UserID,
                KnowIedgeId = para.ID
            };
            praisebll.Create(praiseEntity);
            #endregion
            return(rd);
        }