Пример #1
0
        // GET: Admin
        public ActionResult Index()
        {
            var list = IdNamesService.GetAll().GroupBy(m => m.TypeName).Select(m => new { text = m.Key, value = m.Key });

            ViewBag.TypeNameList = list;
            return(View());
        }
Пример #2
0
        public ActionResult GetList(string name, string typeName, int page = 1, int limit = 10)
        {
            int total;
            var list = IdNamesService.GetPagedData(name, typeName, out total, page, limit);

            return(Json(new AjaxResult {
                Result = true, Data = new { Data = list, Total = total }
            }, JsonRequestBehavior.AllowGet));
        }
Пример #3
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 = "删除成功"
            }));
        }
Пример #4
0
        public ActionResult UploadImage(int id = 0)
        {
            HttpPostedFileBase file = Request.Files[0];

            string fileName = Guid.NewGuid() + file.FileName;
            string path     = Server.MapPath("~/UploadImage/" + fileName);

            file.SaveAs(path);
            if (id > 0)
            {
                IdNamesService.UpdateImage(id, fileName);
            }
            AdminLogService.AddNew("上传图片,图片名称:" + fileName);
            return(Json(new AjaxResult {
                Result = true, Msg = "上传成功", Data = fileName
            }));
        }
Пример #5
0
        public ActionResult Add(IdNameDto idName)
        {
            if (idName.Id <= 0)
            {
                IdNamesService.AddNew(idName);

                AdminLogService.AddNew($"添加基础数据:{idName.Name}");
                return(Json(new AjaxResult {
                    Result = true, Msg = "添加成功"
                }));
            }
            IdNamesService.Update(idName);

            AdminLogService.AddNew($"修改基础数据:{idName.Name}");
            return(Json(new AjaxResult {
                Result = true, Msg = "修改成功"
            }));
        }
Пример #6
0
        public ActionResult Sndex()
        {
            //获取轮播图
            var listShouYeLunBo = IdNamesService.GetByTypeName("首页轮播图");

            ViewBag.ShouYeLunBo = listShouYeLunBo;

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

            ViewBag.ShouYeGongGao = listGongGao;

            //获取快速推荐
            var listTuiJian = IdNamesService.GetByTypeName("课程类型").Where(m => m.Remark == "快速推荐").ToList();

            ViewBag.ShouYeTuiJian = listTuiJian;

            //首页视频推荐
            var listVideoList = VideoService.GetAll().Take(10).ToList();

            ViewBag.ShouYeVideo = listVideoList;
            return(View());
        }
Пример #7
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));
            }
        }