This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpPost] | |
| public ActionResult Delete(Movie movieToDelete) | |
| { | |
| if (ModelState.IsValid) | |
| { | |
| //Update the data in db and show the list of movies | |
| using (var db = new MovieDBContext()) | |
| { | |
| db.Entry(movieToDelete).State = System.Data.Entity.EntityState.Deleted; | |
| db.SaveChanges(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model MicroIMDBV2.Models.Movie | |
| @{ | |
| ViewBag.Title = "Delete"; | |
| } | |
| @using (Html.BeginForm("Delete", "Movie", FormMethod.Post, new { @class = "form-horizontal" })) | |
| { | |
| <h2>Delete Movie</h2> | |
| <div class="form-group"> | |
| @Html.LabelFor(m => m.Title, new { @class = "col-md-2 control-label" }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpGet] | |
| public ActionResult Delete(int id=0) | |
| { | |
| using (var db = new MovieDBContext()) | |
| { | |
| Movie movie = db.Movies.Find(id); | |
| // Find the movie from db | |
| if (movie == null) // There is no movie with the passed id | |
| { | |
| return HttpNotFound(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <td>@Html.ActionLink("Edit","Edit", new {id=@movie.Id})</td> | |
| <td>@Html.ActionLink("Delete", "Delete", new { id = @movie.Id })</td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpPost] | |
| public ActionResult Edit(Movie movieToUpdate) | |
| { | |
| if (ModelState.IsValid) | |
| { | |
| //Update the data in db and show the list of movies | |
| using (var db = new MovieDBContext()) | |
| { | |
| db.Entry(movieToUpdate).State = System.Data.Entity.EntityState.Modified; | |
| db.SaveChanges(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model MicroIMDBV2.Models.Movie | |
| @{ | |
| ViewBag.Title = "Edit"; | |
| } | |
| @using (Html.BeginForm(<strong>"Edit"</strong>, "Movie", FormMethod.Post, new { @class = "form-horizontal" })) | |
| { | |
| <h2>Edit Movie</h2> | |
| <div class="form-group"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpGet] | |
| public ActionResult Edit(int id=0) | |
| { | |
| using (var db = new MovieDBContext()) | |
| { | |
| Movie movie = db.Movies.Find(id); | |
| // Find the movie from db | |
| if(movie==null) // There is no movie with the passed id | |
| { | |
| return HttpNotFound(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model IEnumerable<MicroIMDBV2.Models.Movie> | |
| @{ | |
| ViewBag.Title = "Index"; | |
| } | |
| <h2>Index</h2> | |
| <table class="table"> | |
| <tr> | |
| <th>Title</th> | |
| <th>Year of Release </th> | |
| </tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="~/Scripts/jquery-1.10.2.min.js"></script> | |
| <script src="~/Scripts/bootstrap.min.js"></script> | |
| <script src="~/Scripts/jquery.validate.min.js"></script> | |
| <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <appSettings> | |
| <add key="webpages:Version" value="3.0.0.0" /> | |
| <add key="webpages:Enabled" value="false" /> | |
| <add key="ClientValidationEnabled" value="true" /> | |
| <add key="UnobtrusiveJavaScriptEnabled" value="true" /> | |
| </appSettings> |
NewerOlder