//
// GET: /Movies/Edit/5
public ActionResult Edit(int id = 0)
{
Movie movie = db.Movies.Find(id);
if (movie == null)
{
return HttpNotFound();
}
return View(movie);
}
//
// POST: /Movies/Edit/5
[HttpPost]
public ActionResult Edit(Movie movie)
{
if (ModelState.IsValid)
{
db.Entry(movie).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(movie);
}
In my understanding, HttpPost is only accessible by posting the populated form in the corresponding view. My confusion is whether or not I need to check the nullness of movie
in HttpPost as I think movie
has no chance to be null
. What do you think of it? Is there a chance in which movie
is null
?
Please wisely downvote my question by giving the reason!