コード例 #1
0
        public async Task <IActionResult> ConfirmReservation([FromQuery] int reservationId)
        {
            var reservation = context.Reservations.FirstOrDefault(r => r.ReservationId == reservationId);

            if (reservation == null)
            {
                return(NotFound());
            }
            reservation.Expiration  = null;
            reservation.IsConfirmed = true;
            context.Update(reservation);
            await context.SaveChangesAsync();

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("RoomId,Name")] Room room)
        {
            if (id != room.RoomId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(room);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoomExists(room.RoomId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("GenreMovieID,MovieID,GenreID")] GenreMovie genreMovie)
        {
            if (id != genreMovie.GenreMovieID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genreMovie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenreMovieExists(genreMovie.GenreMovieID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenreID"] = new SelectList(_context.genres, "GenreID", "GenreName", genreMovie.GenreID);
            ViewData["MovieID"] = new SelectList(_context.movies, "MovieID", "Title", genreMovie.MovieID);
            return(View(genreMovie));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("DirectorsID,MovieID,PeopleID")] Directors directors)
        {
            if (id != directors.DirectorsID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(directors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DirectorsExists(directors.DirectorsID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieID"]  = new SelectList(_context.movies, "MovieID", "Title", directors.MovieID);
            ViewData["PeopleID"] = new SelectList(_context.people, "PeopleID", "Name", directors.PeopleID);
            return(View(directors));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ReservationId,ShowingID,Seats,Price")] Reservation reservation)
        {
            if (id != reservation.ReservationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.ReservationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ShowingID"] = new SelectList(_context.showings, "ShowingID", "ShowingID", reservation.ShowingID);
            return(View(reservation));
        }
コード例 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("ShowingID,MovieID,RoomID,StartTime")] Showing showing)
        {
            if (id != showing.ShowingID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(showing);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShowingExists(showing.ShowingID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieID"] = new SelectList(_context.movies, "MovieID", "Title", showing.MovieID);
            ViewData["RoomID"]  = new SelectList(_context.rooms, "RoomId", "Name", showing.RoomID);
            return(View(showing));
        }
コード例 #7
0
        public async Task <ActionResult <ScreeningRoom> > PatchRoom(int id, [FromForm] ScreeningRoom room)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var existingRoom = context.ScreeningRooms.FirstOrDefault(sm => sm.ScreeningRoomId == id);

            if (existingRoom == null)
            {
                return(NotFound());
            }
            if (room.ScreeningRoomId != id)
            {
                return(BadRequest());
            }

            existingRoom.Patch(room);

            context.Update(existingRoom);

            await context.SaveChangesAsync();

            return(new OkObjectResult(room));
        }
コード例 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("PeopleID,Name")] People people)
        {
            if (id != people.PeopleID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(people);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PeopleExists(people.PeopleID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(people));
        }
コード例 #9
0
        public async Task <IActionResult> Edit(int id, [Bind("FilmID,Film_ime,Film_trajanje,Film_reziser,Film_opis,Film_img")] Film film)
        {
            if (id != film.FilmID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(film);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FilmExists(film.FilmID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(film));
        }
コード例 #10
0
ファイル: SeatController.cs プロジェクト: jrizmal/is-kino
        public async Task <IActionResult> Edit(int id, [Bind("SeatID,Row,Number")] Seat seat)
        {
            if (id != seat.SeatID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(seat);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SeatExists(seat.SeatID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(seat));
        }
コード例 #11
0
ファイル: MovieController.cs プロジェクト: jrizmal/is-kino
        public async Task <IActionResult> Edit(int id, [Bind("MovieID,Title,Rating,Length,StartDate,EndDate,CoverImage")] Movie movie)
        {
            if (id != movie.MovieID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.MovieID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
コード例 #12
0
        public async Task <IActionResult> Edit(int id, [Bind("PredstavaID,Predstava_cas,FilmID,DvoranaID")] Predstava predstava)
        {
            if (id != predstava.PredstavaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(predstava);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PredstavaExists(predstava.PredstavaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(predstava));
        }
コード例 #13
0
ファイル: UserController.cs プロジェクト: kriss5a/kino
        public async Task <IActionResult> ChangeUserData(ChangeUserDataViewModel newData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var currentUser = await userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Forbid());
            }

            currentUser.FullName = encoder.Encode(newData.FullName);

            context.Update(currentUser);

            await context.SaveChangesAsync();

            return(new OkObjectResult(newData));
        }
コード例 #14
0
        public async Task <ActionResult <ActionResult <Screening> > > PatchScreening(int id, [FromForm] Screening screening)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var existingScreening = context.Screenings.FirstOrDefault(s => s.ScreeningId == screening.ScreeningId);

            if (existingScreening == null)
            {
                return(NotFound());
            }

            var existingMovie = context.Movies.FirstOrDefault(m => m.MovieId == screening.MovieId);

            if (existingMovie == null)
            {
                return(NotFound());
            }
            screening.Movie = existingMovie;

            var existingScreeningRoom = context.ScreeningRooms.FirstOrDefault(sr => sr.ScreeningRoomId == sr.ScreeningRoomId);

            if (screening.ScreeningId != id)
            {
                return(BadRequest());
            }
            screening.ScreeningRoom = existingScreeningRoom;

            existingScreening.Patch(screening);

            context.Update(existingScreening);

            await context.SaveChangesAsync();

            return(new OkObjectResult(screening));
        }
コード例 #15
0
ファイル: MovieController.cs プロジェクト: kriss5a/kino
        public async Task <ActionResult <Movie> > PatchMovie(int id, [FromForm] Movie movie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var existingMovie = context.Movies.FirstOrDefault(m => m.MovieId == id);

            if (existingMovie == null)
            {
                return(NotFound());
            }
            if (movie.MovieId != id)
            {
                return(BadRequest());
            }

            existingMovie.Patch(movie);
            context.Update(existingMovie);

            await context.SaveChangesAsync();

            return(new OkObjectResult(movie));
        }
コード例 #16
0
 public void Update(T entity)
 {
     _context.Update(entity);
 }