/// <inheritdoc cref="IProjectionDao.ReadProjection(int)"/> public Projection ReadProjection(int projectionId) { using (var stmt = new NpgsqlCommand()) { stmt.Connection = _con; stmt.CommandText = "SELECT * FROM via_cinema_schema.projections" + " WHERE projections.id = @id;"; stmt.Parameters.AddWithValue(ProjectionEntityConstants.IdColumn, projectionId); List <Seat> seatAllocations = ReadSeatReservations(projectionId); using (NpgsqlDataReader reader = stmt.ExecuteReader()) { if (!reader.Read()) { return(null); } var movieName = (string)reader[ProjectionEntityConstants.MovieNameColumn]; Movie movie = _movieDao.Read(movieName); var projStartTime = (DateTime)reader[ProjectionEntityConstants.ProjectionStartColumn]; return(new Projection(projectionId, movie, seatAllocations, projStartTime)); } } }
/// <inheritdoc cref="IMovieBase.GetMovie(string)"/> public Movie GetMovie(string movieName) { Validator.ValidateTextualInput(movieName); if (!_movieCache.ContainsKey(movieName)) { Movie movie = _movieDao.Read(movieName); if (movie == null) { return(null); } _movieCache[movie.Name] = movie; } return(_movieCache[movieName]); }