public async Task <IActionResult> Edit(int id, [Bind("MovieKey,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] MovieListing movieListing) { if (id != movieListing.MovieKey) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movieListing); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieListingExists(movieListing.MovieKey)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movieListing)); }
public async Task <IActionResult> Create([Bind("MovieKey,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] MovieListing movieListing) { if (ModelState.IsValid) { _context.Add(movieListing); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movieListing)); }
private MovieListing BuildMovieListing(IList <Business.Models.MovieSummary> movieSummaries) { if (movieSummaries.IsNullOrEmpty()) { return(null); } var movieListing = new MovieListing { Context = "https://schema.org", Type = "ItemList", ItemListElement = new List <ItemListElement>(movieSummaries.Count) }; var positionIncrement = 0; // Absolute url //var searchResultsUrl = Url.AbsoluteAction(nameof(Index), "Movies"); // Relative Url was used instead of the above absolute as the above absolute url was not valid within the testing tool: https://search.google.com/structured-data/testing-tool var searchResultsUrl = Url.Action(nameof(Index), "Movies"); foreach (var movieSummary in movieSummaries) { movieListing.ItemListElement.Add(new ItemListElement { Type = "ListItem", Position = $"{++positionIncrement}", Item = new MovieItem { Name = movieSummary.Title, Type = "Movie", Image = movieSummary.Poster, // Movie summary only has a single year, so to avoid warnings within the structured data testing tool: https://search.google.com/structured-data/testing-tool , we must place defaults for the dateCreated DateCreated = $"{movieSummary.Year}-01-01", // Url must be unique for each result using the action tag Url = $"{searchResultsUrl}#{movieSummary.imdbID}" } }); } return(movieListing); }
public IActionResult AddMovie(MovieListing movie) { TempStorage.AddMovie(movie); return(View("Confirmation")); }