Example #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Movies.Add(MovieModel.ToMovie());
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MovieModel = MovieModel.FromMovie(await _context.Movies.FindAsync(id));

            if (MovieModel != null)
            {
                _context.Movies.Remove(MovieModel.ToMovie());
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }