Ejemplo n.º 1
0
        public async Task <IActionResult> TestAddMovie()
        {
            // create a new movie to be added
            var title  = $"test_{DateTime.Now}";
            var result = "";
            var movie  = new Movie()
            {
                Title        = title,
                Subcommittee = Subcommittee.Alternative
            };

            try
            {
                var entry = _context.Add(movie);
                await _context.SaveChangesAsync();

                result = $"Truck added successfully.";

                _context.Remove(entry.Entity);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                result = $"Failed to add truck {e.Message};";
            }

            return(RedirectToAction("Complete", routeValues: new { message = result }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Title,PosterUrl,Subcommittee")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,MovieId,ShowDateTime")] Showtime showtime)
        {
            if (ModelState.IsValid)
            {
                _context.Add(showtime);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieId"] = new SelectList(_context.Movie, "Id", "Title", showtime.MovieId);
            return(View(showtime));
        }