public ActionResult DeleteConfirmed(int id) { ToWatchList toWatchList = db.ToWatchList.Find(id); db.ToWatchList.Remove(toWatchList); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Title,Year,GenreID,RatingID,Description,TypeStatusID")] ToWatchList toWatchList) { if (ModelState.IsValid) { db.Entry(toWatchList).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GenreID = new SelectList(db.Genre, "ID", "Description", toWatchList.GenreID); ViewBag.RatingID = new SelectList(db.Rating, "ID", "Description", toWatchList.RatingID); ViewBag.TypeStatusID = new SelectList(db.TypeStatus, "ID", "Description", toWatchList.TypeStatusID); return(View(toWatchList)); }
// GET: ToWatchLists/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ToWatchList toWatchList = db.ToWatchList.Find(id); if (toWatchList == null) { return(HttpNotFound()); } return(View(toWatchList)); }
public IHttpActionResult ToWatch(ToWatchListDto dto) { var userID = User.Identity.GetUserId(); var toWatchList = new ToWatchList { userId = userID, movieId = Convert.ToInt32(dto.movieId) }; DB db = new DB(); db.towatch(toWatchList); return(Ok()); }
// GET: ToWatchLists/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ToWatchList toWatchList = db.ToWatchList.Find(id); if (toWatchList == null) { return(HttpNotFound()); } ViewBag.GenreID = new SelectList(db.Genre, "ID", "Description", toWatchList.GenreID); ViewBag.RatingID = new SelectList(db.Rating, "ID", "Description", toWatchList.RatingID); ViewBag.TypeStatusID = new SelectList(db.TypeStatus, "ID", "Description", toWatchList.TypeStatusID); return(View(toWatchList)); }
public List <ToWatchList> getToWatch() { List <ToWatchList> toWatchMovies = new List <ToWatchList>(); connection.Open(); cmd = new SqlCommand("select * from towatch", connection); rdr = cmd.ExecuteReader(); while (rdr.Read()) { ToWatchList m = new ToWatchList(); m.userId = rdr.GetString(0); m.movieId = rdr.GetInt32(1); toWatchMovies.Add(m); } return(toWatchMovies); }
public void towatch(ToWatchList toWatchList) { try { connection.Open(); string str = " insert into towatch(userid,movieid) values ('" + toWatchList.userId + "',' " + toWatchList.movieId + "') "; //Console.WriteLine(str); cmd = new SqlCommand(str, connection); cmd.ExecuteNonQuery(); } finally { if (connection != null) { connection.Close(); } } }