Ejemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            var idName = IdNamesService.GetById(id);

            IdNamesService.MarkDeleted(id);

            AdminLogService.AddNew($"删除基础数据:{idName.Name}");
            return(Json(new AjaxResult {
                Result = true, Msg = "删除成功"
            }));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            try
            {
                int type = 1;
                if (Session["CourseType"] != null && Session["CourseType"].ToString() != "")
                {
                    type = int.Parse(Session["CourseType"].ToString());
                }
                logger.Info($"type={type}");
                var code   = HttpContext.Request.QueryString["code"];
                var openId = Session["OpenId"].ToString();
                logger.Info($"openId={openId}");
                //没有授权,没有获取
                if (string.IsNullOrEmpty(openId) && string.IsNullOrEmpty(code))
                {
                    return(Redirect("/Authorize/Index?type=" + type));
                }
                //有code,没有openid
                if (string.IsNullOrEmpty(openId) && !string.IsNullOrEmpty(code))
                {
                    //有了code之后,判断如果授权之后,获取用户信息
                    var content    = oauth.GetUserInfo(AppId, Appsecret, code);
                    var wxUserInfo = JsonConvert.DeserializeObject <WxUserInfo>(content);
                    Session["OpenId"] = wxUserInfo.openid;
                    //判断该微信号有没有注册过
                    UserAddDto user = new UserAddDto
                    {
                        AccountNumber    = wxUserInfo.openid,
                        HeadPortraitSrc  = wxUserInfo.headimgurl,
                        RegisterDataTime = DateTime.Now,
                        UserName         = wxUserInfo.nickname,
                        WxAddress        = wxUserInfo.country + "/" + wxUserInfo.province + "/" + wxUserInfo.city,
                        Sex = wxUserInfo.sex == "1"
                    };
                    logger.Info("添加用户信息," + content);
                    UserService.AddNew(user);
                }

                //获取轮播图
                var listShouYeLunBo = IdNamesService.GetByTypeName("首页轮播图");
                ViewBag.ShouYeLunBo = listShouYeLunBo;

                //获取公告
                var listGongGao = IdNamesService.GetByTypeName("首页公告");
                ViewBag.ShouYeGongGao = listGongGao;

                //首页分类
                var model          = IdNamesService.GetById(type);
                var listCourseType = IdNamesService.GetByTypeName(model.Name);
                ViewBag.ShouYeCourseType = listCourseType;
                ViewBag.CourseTypeId     = type;

                //var listVideoList = VideoService.GetAll().Where().Take(10).ToList();
                //ViewBag.ShouYeVideo = listVideoList;
                return(View());
            }
            catch (Exception ex)
            {
                logger.Error("主页加载错误", ex);
                return(Content(ex.Message));
            }
        }