//This is my delete method in business logic public void DeleteMovie(MovieView model) { using (var movierepo = new MovieRepository()) { Movie mov = movierepo.GetById(model.MovieId); movierepo.Delete(mov); } } //My delete method inside the controller public ActionResult DeleteF(MovieView model, int id) { var m = movieLogic.GetById(id); movieLogic.DeleteMovie(m); return RedirectToAction("Index", "Admin"); } [HttpGet] public ViewResult Update(int movieId) { var movie = movieLogic.GetById(movieId); return View(movie); } [HttpPost] public ActionResult Update(MovieView movie, HttpPostedFileBase image = null) { if (ModelState.IsValid) { if (image != null) { movie.MovieArt = image.ContentType; movie.MovieArtData = new byte[image.ContentLength]; image.InputStream.Read(movie.MovieArtData, 0, image.ContentLength); } movieLogic.UpdateMovie(movie); TempData["message"] = string.Format("{0} has been saved", movie.Title); return RedirectToAction("Index"); } else { // there is something wrong with the data values return View(movie); } } //This is part of my view @using (Html.BeginForm("DeleteF", "Admin")) { @Html.AntiForgeryToken() <div class="form-actions no-color"> <input type="submit" value="Yes" class="btn btn-danger" /> <span> @Html.ActionLink("No", "Index", null, new { @class = "btn btn-primary" }) </span> </div> }
Id
http://localhost:56230/controller/DeleteF/1 //Here "1"(ID) is missing
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)