コード例 #1
0
        public JsonResult Delete([FromForm] string token, [FromForm] int caseId)
        {
            DataResult dr = new DataResult();

            try
            {
                if (caseId < 10000)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                CaseBLL    caseBLL    = new CaseBLL();
                CaseEntity caseEntity = caseBLL.GetById(caseId);

                if (caseEntity == null)
                {
                    dr.code = "201";
                    dr.msg  = "不存在该说说";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);
                if (caseEntity.userId != userEntity.userId)
                {
                    dr.code = "201";
                    dr.msg  = "不是该用户的说说";
                    return(Json(dr));
                }

                caseEntity.isDel      = true;
                caseEntity.modifyDate = DateTime.Now;

                int rows = caseBLL.ActionDal.ActionDBAccess.Updateable(caseEntity).ExecuteCommand();

                //增加阅读记录
                ReadBLL readBLL = new ReadBLL();
                readBLL.Create(userEntity.userId, (int)Entity.TypeEnumEntity.TypeEnum.案例, caseId);

                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }
コード例 #2
0
ファイル: EndorseController.cs プロジェクト: 13232989155/A6
        public JsonResult Delete([FromForm] string token, [FromForm] int objId, [FromForm] int type)
        {
            DataResult dr = new DataResult();

            try
            {
                if (objId < 10000 || type < 1)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);


                EndorseBLL    endorseBLL    = new EndorseBLL();
                EndorseEntity endorseEntity = endorseBLL.GetUserIdAndTypeAndObjId(userEntity.userId, type, objId);

                endorseEntity.isDel      = true;
                endorseEntity.modifyDate = DateTime.Now;

                int rows = endorseBLL.ActionDal.ActionDBAccess.Updateable(endorseEntity).ExecuteCommand();
                //增加阅读记录
                ReadBLL readBLL = new ReadBLL();
                readBLL.Create(userEntity.userId, type, objId);
                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }
コード例 #3
0
        public JsonResult GetById([FromForm] string token, [FromForm] int caseOfficialId)
        {
            DataResult dr = new DataResult();

            try
            {
                CaseOfficialEntity caseOfficialEntity = caseOfficialBLL.GetById(caseOfficialId);

                CommentBLL commentBLL = new CommentBLL();
                caseOfficialEntity.commentCount = commentBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.官方案例, caseOfficialEntity.caseOfficialId).Count();

                EndorseBLL           endorseBLL      = new EndorseBLL();
                List <EndorseEntity> endorseEntities = endorseBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.官方案例, caseOfficialEntity.caseOfficialId);

                caseOfficialEntity.endorseCount = endorseEntities.Count();

                UserEntity userEntity = new UserEntity();
                if (!string.IsNullOrWhiteSpace(token))
                {
                    userEntity = this.GetUserByToken(token);
                    if (endorseEntities.ToList().Exists(it => it.userId == userEntity.userId))
                    {
                        caseOfficialEntity.isEndorse = true;
                    }

                    //增加阅读记录
                    ReadBLL readBLL = new ReadBLL();
                    readBLL.Create(userEntity.userId, (int)Entity.TypeEnumEntity.TypeEnum.官方案例, caseOfficialId);
                }

                dr.code = "200";
                dr.data = caseOfficialEntity;
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }

            return(Json(dr));
        }
コード例 #4
0
ファイル: EndorseController.cs プロジェクト: 13232989155/A6
        public JsonResult Create([FromForm] string token, [FromForm] int objId, [FromForm] int type)
        {
            DataResult dr = new DataResult();

            try
            {
                if (objId < 10000 || type < 1)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);

                EndorseBLL endorseBLL = new EndorseBLL();
                int        rows       = endorseBLL.Create(userEntity.userId, type, objId);
                //增加阅读记录
                ReadBLL readBLL = new ReadBLL();
                readBLL.Create(userEntity.userId, type, objId);
                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }
コード例 #5
0
        /// <summary>
        /// 打赏说说
        /// </summary>
        /// <param name="userEntity"></param>
        /// <param name="shareId"></param>
        /// <returns></returns>
        private DataResult SponsorShare(UserEntity userEntity, int shareId)
        {
            DataResult dr = new DataResult();

            ShareBLL shareBLL = new ShareBLL();

            ShareEntity shareEntity = shareBLL.GetById(shareId);

            if (shareEntity.isDel)
            {
                dr.code = "201";
                dr.msg  = "说说已被删除";
                return(dr);
            }
            if (shareEntity.userId < 10000)
            {
                dr.code = "201";
                dr.msg  = "无主说说";
                return(dr);
            }

            var result = shareBLL.ActionDal.ActionDBAccess.Ado.UseTran(() =>
            {
                //积分减1
                userEntity.integral = userEntity.integral - 1;
                var rows1           = shareBLL.ActionDal.ActionDBAccess.Updateable(userEntity).ExecuteCommand();
                IntegralDetailEntity integralDetailEntity = new IntegralDetailEntity()
                {
                    createDate = DateTime.Now,
                    integral   = -1,
                    isDel      = false,
                    modifyDate = DateTime.Now,
                    objId      = shareId,
                    type       = (int)Entity.TypeEnumEntity.TypeEnum.说说,
                    userId     = userEntity.userId
                };
                var rows2 = shareBLL.ActionDal.ActionDBAccess.Insertable(integralDetailEntity).ExecuteCommand();

                //积分加1
                UserEntity user = shareBLL.ActionDal.ActionDBAccess.Queryable <UserEntity>().Where(it => it.userId == shareEntity.userId).First();
                user.integral   = user.integral + 1;
                var rows3       = shareBLL.ActionDal.ActionDBAccess.Updateable(user).ExecuteCommand();
                IntegralDetailEntity integralDetail = new IntegralDetailEntity()
                {
                    createDate = DateTime.Now,
                    integral   = 1,
                    isDel      = false,
                    modifyDate = DateTime.Now,
                    objId      = shareId,
                    type       = (int)Entity.TypeEnumEntity.TypeEnum.说说,
                    userId     = user.userId
                };
                var rows4 = shareBLL.ActionDal.ActionDBAccess.Insertable(integralDetail).ExecuteCommand();

                shareEntity.integral = shareEntity.integral + 1;
                var rows5            = shareBLL.ActionDal.ActionDBAccess.Updateable(shareEntity).ExecuteCommand();
            });
            //增加阅读记录
            ReadBLL readBLL = new ReadBLL();

            readBLL.Create(userEntity.userId, (int)Entity.TypeEnumEntity.TypeEnum.说说, shareId);
            if (result.IsSuccess)
            {
                dr.code = "200";
                dr.msg  = "成功";
            }
            else
            {
                dr.code = "201";
                dr.msg  = "失败";
            }

            return(dr);
        }