예제 #1
0
        public ActionResult Create()
        {
            KPMGNews.Models.LoginData logindata = new KPMGNews.Models.LoginData(HttpContext);
            if (!logindata.usertype().Equals("Publisher"))
            {
                return(RedirectToAction("Index", "News", null));
            }

            return(View());
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            KPMGNews.Models.LoginData logindata = new KPMGNews.Models.LoginData(HttpContext);
            if (!logindata.usertype().Equals("Publisher"))
            {
                return(RedirectToAction("Index", "News", null));
            }

            News news = db.NewsArticle.Find(id);

            news.deleted = true;
            //db.NewsArticle.Remove(news);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult Edit([Bind(Include = "NewsID,Text,UserID,timestamp,deleted")] News news)
        {
            KPMGNews.Models.LoginData logindata = new KPMGNews.Models.LoginData(HttpContext);
            if (!logindata.usertype().Equals("Publisher"))
            {
                return(RedirectToAction("Index", "News", null));
            }

            if (ModelState.IsValid)
            {
                news.timestamp       = DateTime.Now;
                news.UserID          = Convert.ToInt32(HttpContext.Session["UserID"]);
                news.deleted         = false;
                db.Entry(news).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(news));
        }
예제 #4
0
        public ActionResult Edit(int?id)
        {
            KPMGNews.Models.LoginData logindata = new KPMGNews.Models.LoginData(HttpContext);
            if (!logindata.usertype().Equals("Publisher"))
            {
                return(RedirectToAction("Index", "News", null));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            News news = db.NewsArticle.Find(id);

            if (news == null)
            {
                return(HttpNotFound());
            }
            return(View(news));
        }
예제 #5
0
 // GET: Accounts/Create
 public ActionResult LogOut()
 {
     KPMGNews.Models.LoginData logindata = new KPMGNews.Models.LoginData(this.HttpContext);
     logindata.LogOut();
     return(RedirectToAction("Login", "Accounts", null));
 }