コード例 #1
0
        public void AddAiring(AiringMovie airingMovie)
        {
            try
            {
                using (var connection = new SqlConnection(_dbConnectionString))
                {
                    connection.Open();

                    SqlCommand cmd = new SqlCommand("AddAiring", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    cmd.Parameters.Add(new SqlParameter("@RoomId", airingMovie.Room.Number));
                    cmd.Parameters.Add(new SqlParameter("@AiringTime", airingMovie.AiringTime));
                    cmd.Parameters.Add(new SqlParameter("@MovieId", airingMovie.Movie.Id));

                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                //File.AppendAllText(, message);
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #2
0
        public void GetOccupiedSeats(AiringMovie airingMovie)
        {
            try
            {
                using (var connection = new SqlConnection(_dbConnectionString))
                {
                    connection.Open();

                    var cmd = new SqlCommand("GetOccupiedSeats", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    cmd.Parameters.Add(new SqlParameter("@AiringMovieId", airingMovie.Id));

                    var reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        airingMovie.Room.Seats.First(s => s.SeatNumber == (int)reader["SeatNumber"]).IsOccupied =
                            true;
                    }
                }
            }
            catch (Exception ex)
            {
                //File.AppendAllText(, message);
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #3
0
        private void AddAiringMovie(AiringMovie airingMovie, DateTime date)
        {
            const int timeForCleaningInMinutes = 60;

            airingMovie.AiringTime = airingMovie.AiringTime.AddMinutes(timeForCleaningInMinutes);

            _repo.AddAiring(airingMovie);
        }
コード例 #4
0
        private AiringMovie FirstAiringOfTheDay(Movie movie, DateTime date, Room room)
        {
            var earliestAiringTime = new DateTime(date.Year, date.Month, date.Day, 11, 0, 0);
            var airing             = new AiringMovie
            {
                AiringTime = earliestAiringTime,
                Movie      = movie,
                Room       = room
            };

            return(airing);
        }
コード例 #5
0
        private void AddMovieDetailsToAiringMovie(AiringMovie airingMovie)
        {
            var movieId = airingMovie.Movie.Id;

            if (movieId == -1)
            {
                return;
            }

            var movieLogic = new MovieLogic(new MovieContext(), new RoomContext(), new ApiHelper(), new AiringMovieContext());

            airingMovie.Movie = movieLogic.GetMovieById(movieId);
        }
コード例 #6
0
        public AiringMovie GetAiringById(int id)
        {
            var airingMovie = new AiringMovie();

            try
            {
                using (var connection = new SqlConnection(_dbConnectionString))
                {
                    connection.Open();

                    var cmd = new SqlCommand("GetAiringById", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    cmd.Parameters.Add(new SqlParameter("@PlanningId", id));

                    var reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        airingMovie = new AiringMovie
                        {
                            Id         = (int)reader["AiringID"],
                            AiringTime = (DateTime)reader["AiringTime"],
                            Room       = new Room((int)reader["RoomNumber"], reader["RoomType"].ToString(), (int)reader["AvailablePlaces"], (int)reader["SeatsPerRow"]),
                            Price      = (decimal)reader["Price"],
                            Movie      = new Movie
                            {
                                Id = (int)reader["MovieId"]
                            }
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                //File.AppendAllText(, message);
                Console.WriteLine(ex.ToString());
            }

            return(airingMovie);
        }
コード例 #7
0
        public void DeleteAiring(AiringMovie airing)
        {
            try
            {
                using (var connection = new SqlConnection(_dbConnectionString))
                {
                    connection.Open();

                    var sqlCommand = new SqlCommand($"DeleteAiring", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    sqlCommand.Parameters.AddWithValue("@AiringId", airing.Id);

                    sqlCommand.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                //File.AppendAllText(, message);
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #8
0
        public IActionResult Index(AiringMovie model)
        {
            var airing = _transactionLogic.GetAiringMovieById(model.Id);

            return(View("Index", airing));
        }
コード例 #9
0
 public IActionResult GoToReservationPage([FromBody] AiringMovie airing)
 {
     return(new JsonResult(new { response = "Redirect", url = Url.Action("Index", "Transaction", airing) }));
 }
コード例 #10
0
 /// <summary>
 /// DO NUT USE! NOT IMPLEMENTED
 /// </summary>
 /// <param name="airing"></param>
 public void DeleteAiring(AiringMovie airing)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
 /// <summary>
 /// DOES NOTHING!
 /// </summary>
 /// <param name="airingMovie"></param>
 public void AddAiring(AiringMovie airingMovie)
 {
     return;
 }
コード例 #12
0
 public void AddAiring(AiringMovie airingMovie)
 {
     _context.AddAiring(airingMovie);
 }
コード例 #13
0
 public void AddOccupiedSeats(AiringMovie airingMovie)
 {
     _context.GetOccupiedSeats(airingMovie);
 }
コード例 #14
0
 public void DeleteAiring(AiringMovie airing)
 {
     _repo.DeleteAiring(airing);
 }
コード例 #15
0
 public void AddMovieDetailsToAiringMovie2(AiringMovie airingMovie)
 {
     AddMovieDetailsToAiringMovie(airingMovie);
 }
コード例 #16
0
 public void DeleteAiring(AiringMovie airing)
 {
     _airingMovieLogic.DeleteAiring(airing);
 }
コード例 #17
0
        public IActionResult DeleteAiring([FromBody] AiringMovie airing)
        {
            _movieLogic.DeleteAiring(airing);

            return(new JsonResult(new{ message = $"Deleted airing {airing.AiringTime} for {airing.Movie.Title}" }));
        }
コード例 #18
0
 public void DeleteAiring(AiringMovie airing)
 {
     _context.DeleteAiring(airing);
 }