Ejemplo n.º 1
0
        /// <summary>
        /// 详细页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Detail(int id)
        {
            CaseOfficialBLL    caseOfficialBLL    = new CaseOfficialBLL();
            CaseOfficialEntity caseOfficialEntity = caseOfficialBLL.GetById(id);

            return(View(caseOfficialEntity));
        }
Ejemplo n.º 2
0
        public ActionResult <DataResult> Edit([Bind("caseOfficialId,title, coverImage, contents")] CaseOfficialEntity caseOfficialEntity)
        {
            DataResult dataResult = new DataResult();

            try
            {
                if (string.IsNullOrWhiteSpace(caseOfficialEntity.title))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "标题不能为空";
                    return(dataResult);
                }

                if (string.IsNullOrWhiteSpace(caseOfficialEntity.coverImage))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "图片不能为空";
                    return(dataResult);
                }

                if (string.IsNullOrWhiteSpace(caseOfficialEntity.contents))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "内容不能为空";
                    return(dataResult);
                }

                CaseOfficialBLL    caseOfficialBLL = new CaseOfficialBLL();
                CaseOfficialEntity caseOfficial    = caseOfficialBLL.GetById(caseOfficialEntity.caseOfficialId);

                caseOfficial.contents   = caseOfficialEntity.contents;
                caseOfficial.title      = caseOfficialEntity.title;
                caseOfficial.coverImage = caseOfficialEntity.coverImage;
                caseOfficial.modifyDate = DateTime.Now;

                int rows = caseOfficialBLL.ActionDal.ActionDBAccess.Updateable(caseOfficial).ExecuteCommand();

                if (rows > 0)
                {
                    dataResult.code = "200";
                    dataResult.msg  = "成功";
                }
                else
                {
                    dataResult.code = "201";
                    dataResult.msg  = "失败";
                }
            }
            catch (Exception e)
            {
                dataResult.code = "999";
                dataResult.msg  = e.Message;
                return(dataResult);
            }

            return(dataResult);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Delete(int id)
        {
            CaseOfficialBLL    caseOfficialBLL    = new CaseOfficialBLL();
            CaseOfficialEntity caseOfficialEntity = caseOfficialBLL.GetById(id);

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

            int rows = caseOfficialBLL.ActionDal.ActionDBAccess.Updateable(caseOfficialEntity).ExecuteCommand();

            return(RedirectToAction("List"));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 打赏官方案例
        /// </summary>
        /// <param name="userEntity"></param>
        /// <param name="caseOfficialId"></param>
        /// <returns></returns>
        private DataResult SponsorCaseOfficial(UserEntity userEntity, int caseOfficialId)
        {
            DataResult dr = new DataResult();

            CaseOfficialBLL    caseOfficialBLL    = new CaseOfficialBLL();
            CaseOfficialEntity caseOfficialEntity = caseOfficialBLL.GetById(caseOfficialId);

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

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

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

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

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

            return(dr);
        }
Ejemplo n.º 6
0
        public ActionResult <DataResult> Create([Bind("title, coverImage, contents")] CaseOfficialEntity caseOfficialEntity)
        {
            DataResult dataResult = new DataResult();

            try
            {
                if (string.IsNullOrWhiteSpace(caseOfficialEntity.title))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "标题不能为空";
                    return(dataResult);
                }

                if (string.IsNullOrWhiteSpace(caseOfficialEntity.coverImage))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "图片不能为空";
                    return(dataResult);
                }

                if (string.IsNullOrWhiteSpace(caseOfficialEntity.contents))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "内容不能为空";
                    return(dataResult);
                }
                AdminBLL    adminBLL    = new AdminBLL();
                AdminEntity adminEntity = adminBLL.GetById(ThisAdmin().adminId);

                CaseOfficialEntity caseOfficial = new CaseOfficialEntity()
                {
                    contents   = caseOfficialEntity.contents,
                    coverImage = caseOfficialEntity.coverImage,
                    createDate = DateTime.Now,
                    integral   = 0,
                    isDel      = false,
                    modifyDate = DateTime.Now,
                    state      = -1,
                    title      = caseOfficialEntity.title,
                    userId     = adminEntity.userId
                };

                int rows = adminBLL.ActionDal.ActionDBAccess.Insertable(caseOfficial).ExecuteCommand();

                if (rows > 0)
                {
                    dataResult.code = "200";
                    dataResult.msg  = "成功";
                }
                else
                {
                    dataResult.code = "201";
                    dataResult.msg  = "失败";
                }
            }
            catch (Exception e)
            {
                dataResult.code = "999";
                dataResult.msg  = e.Message;
                return(dataResult);
            }

            return(dataResult);
        }