Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("id,startTime,endTime,price,theaterid,movieid,status")] MovieShow movieShow)
        {
            Customer cus = null;

            if (!Auth.isAdmin(HttpContext, ref cus))
            {
                return(Unauthorized());
            }
            ViewBag.customer = cus;
            if (ModelState.IsValid)
            {
                _context.Add(movieShow);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["movieid"]   = new SelectList(_context.Movies, "id", "name", movieShow.movieid);
            ViewData["theaterid"] = new SelectList(_context.Theater, "id", "name", movieShow.theaterid);
            return(View(movieShow));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("id,posterURL,name,description,releaseDate,actors,duration,trailerURL,genreid,status")] Movie movie)
        {
            Customer cus = null;

            if (!Auth.isAdmin(HttpContext, ref cus))
            {
                return(Unauthorized());
            }
            ViewBag.customer = cus;

            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["genreid"] = new SelectList(_context.Genres, "id", "name", movie.genreid);
            return(View(movie));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("id,name,status,rows,cols")] Theater theater)
        {
            Customer cus = null;

            if (!Auth.isAdmin(HttpContext, ref cus))
            {
                return(Unauthorized());
            }
            ViewBag.customer = cus;

            if (ModelState.IsValid)
            {
                await _context.AddAsync(theater);

                await _context.SaveChangesAsync();

                for (int i = 0; i < theater.rows; ++i)
                {
                    for (int j = 0; j < theater.cols; ++j)
                    {
                        Seat seat = new Seat
                        {
                            r         = i,
                            c         = j,
                            theaterid = theater.id
                        };
                        await _context.AddAsync(seat);
                    }
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(theater));
        }