Esempio n. 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));
        }
Esempio n. 2
0
        /// <summary>
        /// 详细页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Detail(int id)
        {
            CaseBLL    caseBLL    = new CaseBLL();
            CaseEntity caseEntity = caseBLL.GetById(id);

            CaseTagCorrelationBLL caseTagCorrelationBLL = new CaseTagCorrelationBLL();

            caseEntity.caseTagEntities = caseTagCorrelationBLL.CaseTagListByCaseId(caseEntity.caseId);

            CaseStepBLL caseStepBLL = new CaseStepBLL();

            caseEntity.caseStepEntities = caseStepBLL.ListByCaseId(caseEntity.caseId);

            return(View(caseEntity));
        }
Esempio n. 3
0
        public JsonResult GetById([FromForm] string token, [FromForm] int caseId)
        {
            DataResult dr = new DataResult();

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

                CommentBLL commentBLL = new CommentBLL();
                caseEntity.commentCount = commentBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.案例, caseEntity.caseId).Count();

                EndorseBLL           endorseBLL      = new EndorseBLL();
                List <EndorseEntity> endorseEntities = endorseBLL.ListByTypeAndObjId((int)Entity.TypeEnumEntity.TypeEnum.案例, caseEntity.caseId);

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

                CaseStepBLL caseStepBLL = new CaseStepBLL();
                caseEntity.caseStepEntities = caseStepBLL.ListByCaseId(caseEntity.caseId);

                CaseTagCorrelationBLL caseTagCorrelationBLL = new CaseTagCorrelationBLL();
                caseEntity.caseTagEntities = caseTagCorrelationBLL.CaseTagListByCaseId(caseEntity.caseId);

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

            return(Json(dr));
        }
Esempio n. 4
0
        /// <summary>
        /// 打赏案例
        /// </summary>
        /// <param name="userEntity"></param>
        /// <param name="caseId"></param>
        /// <returns></returns>
        private DataResult SponsorCase(UserEntity userEntity, int caseId)
        {
            DataResult dr = new DataResult();

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

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

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

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

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

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

            return(dr);
        }