public ActionResult DeleteConfirmed(int id) { LatestNew latestNew = db.LatestNews.Find(id); db.LatestNews.Remove(latestNew); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "NewsId,UserId,Title,NewsScreenshotPath,SourceLink,DateAdded")] LatestNew latestNew) { if (ModelState.IsValid) { latestNew.UserId = Convert.ToString(Session["Administrator"]); db.Entry(latestNew).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", latestNew.UserId); return(View(latestNew)); }
// GET: LatestNews/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LatestNew latestNew = db.LatestNews.Find(id); if (latestNew == null) { return(HttpNotFound()); } return(View(latestNew)); }
public ActionResult Create([Bind(Include = "Title,NewsScreenshotPath,SourceLink")] LatestNew latestNew) { if (ModelState.IsValid) { latestNew.UserId = Convert.ToString(Session["Administrator"]); latestNew.DateAdded = DateTime.Now; db.LatestNews.Add(latestNew); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", latestNew.UserId); return(View(latestNew)); }
// GET: LatestNews/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LatestNew latestNew = db.LatestNews.Find(id); if (latestNew == null) { return(HttpNotFound()); } ViewBag.checkCandidateLogin = true; string UserId = Convert.ToString(Session["Administrator"]); if (UserId == "") { ViewBag.checkCandidateLogin = false; } return(View(latestNew)); }