public async Task <IActionResult> Edit(int id, [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 (id != movieShow.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieShow);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieShowExists(movieShow.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [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 (id != movie.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["genreid"] = new SelectList(_context.Genres, "id", "name", movie.genreid);
            return(View(movie));
        }