コード例 #1
0
        //刪除管理員
        public ActionResult Delete(int?MaId)
        {
            Mager mager = context.Mager.Find(MaId);

            context.Mager.Remove(mager);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
ファイル: BackController.cs プロジェクト: APonSu/EZgo
        //刪除管理員
        public ActionResult AuthDelete(int?id)
        {
            Mager mager = db.Mager.Find(id);

            db.Mager.Remove(mager);
            db.SaveChanges();
            return(RedirectToAction("AuthIndex"));
        }
コード例 #3
0
ファイル: BackController.cs プロジェクト: APonSu/EZgo
        //編輯管理員權限
        public ActionResult AuthEdit(int?id)
        {
            if (Session["Authority"] == null || Session["Authority"].ToString().Contains("A") != true)
            {
                ViewBag.error = "您無此權限";
            }
            Mager mager = db.Mager.Find(id);

            return(View(mager));
        }
コード例 #4
0
ファイル: BackController.cs プロジェクト: APonSu/EZgo
        public ActionResult AuthEdit(Mager mager, string bc, string cc, string dc)
        {
            var mag = db.Mager.Where(m => m.MaId == mager.MaId).FirstOrDefault();

            if (ModelState.IsValid)
            {
                mag.Authority = bc + cc + dc;
                db.SaveChanges();
                TempData["AuthEditResult"] = true;
                return(RedirectToAction("AuthIndex"));
            }
            return(View());
        }
コード例 #5
0
 public ActionResult Create(Mager mager, bool edit, bool delete, bool create) //傳入view所帶來的checkbox參數
 {
     if (ModelState.IsValid)
     {
         int    Authority  = 0;
         String AuthorityS = "";
         Authority       += create ? 1 : 0; //三元運算子
         AuthorityS      += create ? "新增" + "\t" : "";
         Authority       += delete ? 2 : 0;
         AuthorityS      += delete ? "刪除" + "\t" : "";
         Authority       += edit ? 4 : 0;
         AuthorityS      += edit ? "修改" + "\t" : "";
         mager.Authority  = Authority;
         mager.AuthorityS = AuthorityS;
         context.Mager.Add(mager);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mager));
 }
コード例 #6
0
        public ActionResult Edit(Mager mager, bool edit, bool delete, bool create, int?MaId)
        {
            var mag = context.Mager.Where(m => m.MaId == MaId).FirstOrDefault();

            if (ModelState.IsValid)
            {
                int    Authority  = 0;
                String AuthorityS = "";
                Authority     += create ? 1 : 0;
                AuthorityS    += create ? "新增" + "\t" : "";
                Authority     += delete ? 2 : 0;
                AuthorityS    += delete ? "刪除" + "\t" : "";
                Authority     += edit ? 4 : 0;
                AuthorityS    += edit ? "修改" + "\t" : "";
                mag.Authority  = Authority;
                mag.AuthorityS = AuthorityS;
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(mager));
        }
コード例 #7
0
ファイル: BackController.cs プロジェクト: APonSu/EZgo
        public ActionResult AuthCreate(Mager mager, string bc, string cc, string dc)
        {
            var result = db.Mager.Where(m => m.MaAct == mager.MaAct).FirstOrDefault();

            if (result != null)
            {
                ViewBag.Message = "此管理員帳號已被註冊";
                return(View());
            }
            else if (ModelState.IsValid)
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                string pwd = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(mager.MaPwd)), 4, 8);
                mager.MaPwd     = pwd.Replace("-", "");
                mager.Authority = bc + cc + dc;
                db.Mager.Add(mager);
                db.SaveChanges();
                TempData["AuthCreateResult"] = true;
                return(RedirectToAction("AuthIndex"));
            }
            return(View());
        }
コード例 #8
0
        //編輯管理員權限
        public ActionResult Edit(int?MaId)
        {
            if (Session["mag"] == null)
            {
                return(RedirectToAction("Login", "MagerLogin"));
            }
            if (MaId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mager Mager = context.Mager.Find(MaId);

            if (Mager == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AuthS = Session["AuthS"];
            if (ViewBag.AuthS.Contains("管理權限"))
            {
                return(View("Edit", "_Layout_TopManager", Mager));
            }
            return(View("Edit", "_Layout_Manager", Mager));
        }
コード例 #9
0
        public IEnumerable <Mager> PaginatedMager()
        {
            int start = (CurrentPage - 1) * PageSize;

            return(Mager.OrderBy(m => m.MaId).Skip(start).Take(PageSize));
        }