public ActionResult DeleteConfirmed(int id) { Chirps chirps = db.Chirps.Find(id); db.Chirps.Remove(chirps); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,UserId,Text,CreateDateTime,Liked")] Chirps chirps) { if (ModelState.IsValid) { db.Entry(chirps).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", chirps.UserId); return(View(chirps)); }
// GET: Chirps/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Chirps chirps = db.Chirps.Find(id); if (chirps == null) { return(HttpNotFound()); } return(View(chirps)); }
public ActionResult AddChirp(int UserId, string Text) { Chirps tempChirp = new Chirps(); tempChirp.Text = Text; tempChirp.CreateDateTime = DateTime.Now; User tempUser = db.Users.Find(UserId); tempChirp.UserId = tempUser.Id; db.Chirps.Add(tempChirp); db.SaveChanges(); return(Redirect(Request.UrlReferrer.ToString())); }
// GET: Chirps/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Chirps chirps = db.Chirps.Find(id); if (chirps == null) { return(HttpNotFound()); } ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", chirps.UserId); return(View(chirps)); }