コード例 #1
0
        public ActionResult SoftDownList()
        {
            int           UserID     = int.Parse(TakeCookie.GetCookie("userId"));
            Tb_ApplyTable modelTable = (Tb_ApplyTable)mHelp.GetModelBy <Tb_ApplyTable>(m => m.UserID == UserID);

            if (modelTable != null)
            {
                List <Tb_ApplySoftList> list = mHelp.GetListBy <Tb_ApplySoftList>(m => m.ApplyID == modelTable.ApplyID);
                if (list != null)
                {
                    List <Tb_SoftList> listSoft = new List <Tb_SoftList>();
                    foreach (Tb_ApplySoftList item in list)
                    {
                        Tb_SoftList soft = (Tb_SoftList)mHelp.GetModelBy <Tb_SoftList>(m => m.SoftID == item.SoftID);
                        if (soft != null)
                        {
                            listSoft.Add(soft);
                        }
                    }
                    if (listSoft != null)
                    {
                        ViewBag.listSoft = listSoft;
                        return(View());
                    }
                }
            }
            return(View("index"));
            //List<Tb_SoftList> listSoft = mHelp.GetAll<Tb_SoftList>();
        }
コード例 #2
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            bool Pass = false;

            if (TakeCookie.GetCookie("userId") == null) //如果没有cookie,则未登陆
            {
                httpContext.Response.StatusCode = 401;  //无权限状态码
                Pass = false;
            }
            else
            {
                if (TakeCookie.GetCookie("userRole") != null)
                {
                    if (Roles.Contains(TakeCookie.GetCookie("userRole")))
                    {
                        Pass = true;
                    }
                    else
                    {
                        httpContext.Response.StatusCode = 401;//无权限状态码
                        Pass = false;
                    }
                }
                else
                {
                    Pass = false;
                }
            }

            return(Pass);
        }
コード例 #3
0
 //[Common.Skip]
 public ActionResult Index()
 {
     TakeCookie.DelCookie("userId");
     TakeCookie.DelCookie("userRole");
     ViewBag.title = "登陆页面";
     return(View());
 }
コード例 #4
0
        public ActionResult GetPersonalInfo(Admin adminInfo)
        {
            //数据库帮助类
            ModelHelpers modelHelp = new ModelHelpers();

            //获取用户(教师)cookie,cookie存储是ID
            try
            {
                string adminId = TakeCookie.GetCookie("userId");
                adminInfo.Id  = new Guid(adminId);
                adminInfo.Pwd = adminInfo.Pwd.Trim();
                if (string.IsNullOrEmpty(adminInfo.Pwd) || adminInfo.Pwd == "不修改就不需要输入")
                {
                    modelHelp.Modify <Admin>(adminInfo, new string[] { "Id", "Account", "UserName", "Sex" });
                    TempData["res"] = "修改成功";
                    return(RedirectToAction("GetPersonalInfo"));
                }
                modelHelp.Modify <Admin>(adminInfo, new string[] { "Id", "Account", "UserName", "Pwd", "Sex" });
                TempData["res"] = "修改成功";
            }
            catch (Exception)
            {
                TempData["res"] = "<font color='red'>修改失败,请点解cancel或刷新 后 重新输入!<font/>";
            }

            return(RedirectToAction("GetPersonalInfo"));
        }
コード例 #5
0
        public ActionResult GetPersonalInfo()
        {
            //获取用户(教师)cookie,cookie存储是ID
            string      teacherId = TakeCookie.GetCookie("userId");
            TeacherInfo teacher   = db.TeacherInfo.Where(t => t.Id == new Guid(teacherId)).FirstOrDefault();

            return(View(teacher));
        }
コード例 #6
0
        public ActionResult GetPersonalInfo()
        {
            //获取用户(教师)cookie,cookie存储是ID
            string adminId   = TakeCookie.GetCookie("userId");
            Admin  adminInfo = db.Admin.Where(a => a.Id == new Guid(adminId)).FirstOrDefault();

            return(View(adminInfo));
        }
コード例 #7
0
        public ActionResult Courses()
        {
            //获取用户(教师)cookie,cookie存储是ID
            string        teacherId  = TakeCookie.GetCookie("userId");
            List <Course> listCourse = db.Course.Where(c => c.TeacherId == new Guid(teacherId)).ToList();

            ViewBag.Course = listCourse;
            return(View());
        }
コード例 #8
0
        /// <summary>
        /// 管理员 管理教师页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AdminCoureseView()
        {
            //获取用户(教师)cookie,cookie存储是ID
            Guid          adminId    = new Guid(TakeCookie.GetCookie("userId"));
            List <Course> listCourse = db.Course.ToList();

            ViewBag.Course = listCourse;
            return(View());
        }
コード例 #9
0
        public ActionResult AddNewCourse(Course course)
        {
            string teacherId = TakeCookie.GetCookie("userId");

            course.CourseStatus = 0;
            course.TeacherId    = new Guid(teacherId);
            ModelHelpers mHelp = new ModelHelpers();

            mHelp.Add <Course>(course);
            return(RedirectToAction("CoursesDetail", new { id = course.Id }));
        }
コード例 #10
0
        public ActionResult ApplySuccess()
        {
            int           id    = int.Parse(TakeCookie.GetCookie("userId"));
            Tb_ApplyTable model = (Tb_ApplyTable)mHelp.GetModelBy <Tb_ApplyTable>(m => m.UserID == id);

            if (model != null)
            {
                ViewBag.appID = model.ApplyID;
            }
            return(View());
        }
コード例 #11
0
        //
        // GET: /App/

        //用于启动控制器时显示菜单信息
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            int UserID = int.Parse(TakeCookie.GetCookie("userId"));

            if (UserID != 0)
            {
                base.OnActionExecuted(filterContext);
            }
            else
            {
            }
        }
コード例 #12
0
        public ActionResult EditApplyTable(Tb_ApplyTable tb_applytable)
        {
            //对于不能由用户填写的字段手动赋值
            tb_applytable.RecordTime = DateTime.Now;
            tb_applytable.IsPass     = 0;
            tb_applytable.UserID     = int.Parse(TakeCookie.GetCookie("userId"));


            //判断模型状态是否验证通过
            if (ModelState.IsValid)
            {
                db.Entry(tb_applytable).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("ApplySuccess"));
            }
            return(RedirectToAction("ApplySuccess", "SoftDown"));
        }
コード例 #13
0
        public ActionResult ReplyQusetion(FormCollection form)
        {
            Question que = new Question();
            Guid     id  = new Guid(TakeCookie.GetCookie("userid"));

            que.Title   = form["Title"];
            que.Content = form["Content"];
            string[] accountAndId = form["hiddenIA"].Split('#');
            que.ToId        = new Guid(accountAndId[1]);
            que.ToAcconut   = accountAndId[0];
            que.FromId      = id;
            que.FromAccount = accountAndId[2];
            que.Flag        = "未读";
            que.CreateTime  = DateTime.Now.ToShortDateString();

            mHelp.Add <Question>(que);
            return(RedirectToAction("QusetionCenter"));
        }
コード例 #14
0
        //[Common.Skip]
        public ActionResult Index(Tb_SoftUser userModel)
        {
            //根据页面传来的值,调用GetUser方法
            Tb_SoftUser user = GetUser(userModel);

            if (user == null)
            {
                return(View());
            }
            else
            {
                //保存user 到cookie
                TakeCookie.SetCookie("userId", user.UserID.ToString());

                if (user.UserType == 0)//普通用户
                {
                    TakeCookie.SetCookie("userRole", "user");
                    Tb_ApplyTable modelTable = (Tb_ApplyTable)mHelp.GetModelBy <Tb_ApplyTable>(m => m.UserID == user.UserID);
                    if (modelTable != null)         //如果已经有过申请,不得再次申请
                    {
                        if (modelTable.IsPass == 0) //如果申请未通过,则进入未通过界面
                        {
                            return(RedirectToAction("ApplySuccess"));
                        }
                        else//如果通过,则进入软件下载界面
                        {
                            return(RedirectToAction("SoftDownList"));
                        }
                    }
                    else//如果没有申请,进入申请界面
                    {
                        return(View("ApplyTable"));
                    }
                }
                else//管理员用户
                {
                    TakeCookie.SetCookie("userRole", "admin");
                    return(RedirectToAction("ApplyList"));
                }
            }


            //跳转到ApplyList方法
        }
コード例 #15
0
 public ActionResult ApplyTable(Tb_ApplyTable ApplyTable)
 {
     ApplyTable.RecordTime = DateTime.Today;
     ApplyTable.UserID     = int.Parse(TakeCookie.GetCookie("userId"));
     ApplyTable.IsPass     = 0;
     //ModelState.IsValid用于
     if (ModelState.IsValid)
     {
         if (mHelp.Add <Tb_ApplyTable>(ApplyTable) > 0)
         {
             Session["ApplyID"] = ApplyTable.ApplyID;
             return(RedirectToAction("SoftList", new { id = ApplyTable.ApplyID }));
         }
         else
         {
             return(View());
         }
     }
     return(View("index"));
 }
コード例 #16
0
        public ActionResult GetPersonalInfo(TeacherInfo teacherInfo)
        {
            try
            {
                //获取用户(教师)cookie,cookie存储是ID
                string teacherId = TakeCookie.GetCookie("userId");
                teacherInfo.Id  = new Guid(teacherId);
                teacherInfo.Pwd = teacherInfo.Pwd.Trim();
                if (string.IsNullOrEmpty(teacherInfo.Pwd) || teacherInfo.Pwd == "不修改就不需要输入")
                {
                    modelHelp.Modify <TeacherInfo>(teacherInfo, new string[] { "Id", "Account", "UserName", "Sex" });
                    TempData["res"] = "修改成功";
                    return(RedirectToAction("GetPersonalInfo"));
                }
                modelHelp.Modify <TeacherInfo>(teacherInfo, new string[] { "Id", "Account", "UserName", "Pwd", "Sex" });
                TempData["res"] = "修改成功";
            }
            catch (Exception)
            {
                TempData["res"] = "<font color='red'>修改失败,请点解cancel或刷新 后 重新输入!<font/>";
            }

            return(RedirectToAction("GetPersonalInfo"));
        }
コード例 #17
0
        public ActionResult AdminAddComment(FormCollection form)
        {
            Guid adminId = new Guid(TakeCookie.GetCookie("userId"));

            try
            {
                db.Admin.Where(s => s.Id == adminId).FirstOrDefault();
                BlogReply br = new BlogReply
                {
                    BlogId       = Convert.ToInt32(form["BlogID"]),
                    ReplyId      = adminId,
                    ReplyAccount = db.Admin.Where(s => s.Id == adminId).FirstOrDefault().Account,
                    ReplyContent = form["Content"],
                    CreatTime    = DateTime.Now.ToLongDateString() + DateTime.Now.ToShortTimeString()
                };

                mHelp.Add <BlogReply>(br);
                return(RedirectToAction("AdminGetBlogDetail", "LoadMore", new { id = br.BlogId }));
            }
            catch (Exception)
            {
                return(RedirectToAction("AdminGetBlogDetail", "LoadMore", new { id = Convert.ToInt32(form["BlogID"]) }));
            }
        }
コード例 #18
0
 public ActionResult loginOut()
 {
     TakeCookie.DelCookie("userId");
     TakeCookie.DelCookie("userRole");
     return(View("Index"));
 }