Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Chirps chirps = db.Chirps.Find(id);

            db.Chirps.Remove(chirps);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
        // 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));
        }
Ejemplo n.º 4
0
        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()));
        }
Ejemplo n.º 5
0
        // 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));
        }