Пример #1
0
        //編輯影音文章(顯示編輯畫面)
        public ActionResult Edit(int?id)
        {
            if (Session["mag"] == null)
            {
                return(RedirectToAction("Login", "MagerLogin"));
            }
            ViewData["Date"] = DateTime.Now;

            if (id == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }
            Arti Arti = context.Arti.Find(id);

            if (Arti == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AuthS = Session["AuthS"];
            if (ViewBag.AuthS.Contains("管理權限"))//如果登入者的權限有"管理權限"字串,給最高管理者專屬的layout。
            {
                return(View("Edit", "_Layout_TopManager", Arti));
            }
            return(View("Edit", "_Layout_Manager", Arti));//登入者為管理者,給管理者專屬的layout。
        }
Пример #2
0
        public ActionResult ArtiCreate(Arti article, HttpPostedFileBase ArFile, string hd)
        {
            //上傳檔案
            string fileName = "";

            if (ArFile != null)
            {
                if (ArFile.ContentLength > 0)
                {
                    fileName = Path.GetFileName(ArFile.FileName);
                    var path = Path.Combine(Server.MapPath("~/EZgoPDF"), fileName);
                    ArFile.SaveAs(path);
                    article.ArFromWeb = hd;
                }
            }
            var result = db.Arti.Where(m => m.ArFromWeb == article.ArFromWeb).FirstOrDefault();

            if (result != null)
            {
                ViewBag.Message = "此文章已上架,新增失敗";
                return(View(article));
            }
            else
            {
                article.ArPublishTime = DateTime.Now;
                db.Arti.Add(article);
                db.SaveChanges();
                TempData["ArtiCreateResult"] = true;  //顯示新增文章成功視窗用
                return(RedirectToAction("ArtiIndex"));
            }
        }
Пример #3
0
        public ActionResult Delete(int?ArId)
        {
            Arti Arti = context.Arti.Find(ArId);

            context.Arti.Remove(Arti);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "ArId,ArName,ArCt")] Arti Arti)
 {
     if (ModelState.IsValid)
     {
         context.Entry(Arti).State = EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(Arti));
 }
Пример #5
0
        //影音文章編輯
        public ActionResult ArtiEdit(int id)
        {
            if (Session["Authority"] == null || Session["Authority"].ToString().Contains("D") != true)
            {
                ViewBag.error = "您無此權限";
            }
            Arti p = db.Arti.Find(id);

            return(View(p));
        }
Пример #6
0
        public ActionResult Create(Arti Arti)
        {
            if (ModelState.IsValid)
            {
                context.Arti.Add(Arti);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(Arti));
        }
Пример #7
0
        public ActionResult ArtiEdit(Arti article)
        {
            var arti = db.Arti.Where(m => m.ArId == article.ArId).FirstOrDefault();

            arti.ArTitle       = article.ArTitle;
            arti.ArFromWeb     = article.ArFromWeb;
            arti.ArType        = article.ArType;
            arti.ArCont        = article.ArCont;
            arti.ArPublishTime = DateTime.Now;
            db.SaveChanges();
            TempData["ArtiEditResult"] = true;  //顯示編輯文章成功視窗用
            return(RedirectToAction("ArtiIndex"));
        }
Пример #8
0
        public IEnumerable <Arti> PaginatedArti()
        {
            int start = (CurrentPage - 1) * PageSize;

            return(Arti.OrderBy(m => m.ArId).Skip(start).Take(PageSize));
        }