// Parameter in URL are // m: Movie id. // f: Movie Format id. // t: Theater id. protected void Page_Load(object sender, EventArgs e) { ManageMovieCatalog mmc = new ManageMovieCatalog(); mmc.catalogNameFileName = @ConfigurationManager.AppSettings[GlobalConstants.FileMoviesCatalogKey]; mmc.moviesFileName = @ConfigurationManager.AppSettings[GlobalConstants.FileMoviesKey]; mmc.dbConnection = @ConfigurationManager.AppSettings[GlobalConstants.ConnectionKey]; movieList = mmc.RetrieveMovieList(); mc = mmc.RetriveMovieCatalog(); string m = Request.QueryString["m"]; string t = Request.QueryString["t"]; string f = Request.QueryString["f"]; if (m == null) { m = "0"; } if (t == null) { t = "-1"; } if (f == null) { f = "-1"; } if (!IsPostBack) { LoadData(m, ref f, ref t); LoadDetailedData(m, ref f, ref t); } }
public ReturnController(ClientManager cm, BookCatalog bc, MusicCatalog muc, MovieCatalog moc, MagazineCatalog mac, IdentityMap imap) { _cm = cm; _bookc = bc; _moviec = moc; _musicc = muc; _magazinec = mac; _identityMap = imap; }
public HomeController(ClientStore cs, BookCatalog bc, MusicCatalog muc, MovieCatalog moc, MagazineCatalog mac, Search search) { _cs = cs; _bookc = bc; _moviec = moc; _musicc = muc; _magazinec = mac; _search = search; }
public CartController(ClientManager cm, BookCatalog bc, MusicCatalog muc, MovieCatalog moc, MagazineCatalog mac, IdentityMap imap, ModelCopyCatalog modelCopyCatalog) { _cm = cm; _bookc = bc; _moviec = moc; _musicc = muc; _magazinec = mac; _identityMap = imap; _modelCopyCatalog = modelCopyCatalog; }
public async void LoadAsync() { await MovieCatalog.LoadAsync(); await TheaterCatalog.LoadAsync(); await ShowCatalog.LoadAsync(); await TicketCatalog.LoadAsync(); }
public async void SaveAsync() { await MovieCatalog.SaveAsync(); await TheaterCatalog.SaveAsync(); await ShowCatalog.SaveAsync(); await TicketCatalog.SaveAsync(); }
/// <summary> /// Helper method to load a JSON file and deserialized to proper structure. NOTE: This is the movie catalog. /// </summary> /// <returns>An object of type MovieCatalog that contains helper information when consumed by third-party.</returns> public MovieCatalog RetriveMovieCatalog() { MovieCatalog mc = null; string s; using (StreamReader reader = new StreamReader(catalogNameFileName)) { s = reader.ReadToEnd(); } mc = JsonConvert.DeserializeObject <MovieCatalog>(s); return(mc); }
/// <summary> /// For convenience, the constructor creates some sample Movie /// and Studio domain objects, and adds them to the catalogs. /// </summary> private DomainModel() { _movieCatalog = new MovieCatalog(); _studioCatalog = new StudioCatalog(); _movieCatalog.Create(new Movie(0, "Alien", 1979, 112, "Paramount")); _movieCatalog.Create(new Movie(1, "Terminator", 1984, 96, "20th Century Fox")); _movieCatalog.Create(new Movie(2, "Inception", 2010, 143, "New Line Cinema")); _movieCatalog.Create(new Movie(3, "Se7en", 1995, 124, "Paramount")); _movieCatalog.Create(new Movie(4, "Arrival", 2016, 130, "20th Century Fox")); _studioCatalog.Create(new Studio(5, "Paramount", "New York", 8000)); _studioCatalog.Create(new Studio(6, "20th Century Fox", "New York", 2500)); _studioCatalog.Create(new Studio(7, "New Line Cinema", "Boston", 4000)); }
public Result <MovieCatalogDto> GetCatalog(string customerId) { var customer = _customersGetter.Get(customerId); if (customer.HasNoValue) { return(Result.Fail <MovieCatalogDto>(Errors.CustomerNotFound)); } var movies = _moviesGetter.GetAll(); var movieCatalog = new MovieCatalog(movies, new MoviePriceCalculatorFactory()); var movieOffers = movieCatalog.GetMovies(customer.Value); return(Result.Ok(MovieCatalogDtoMapper.MapToDto(movieOffers))); }
public MovieCatalogTests() { DateProviderFactory.DateProvider = Mock.Of <IDateProvider>(); var movies = new List <Movie> { new Movie { Id = MovieId, Title = MovieName, Price = new MoviePrice(TwoDaysMoviePrice, LifeLongMoviePrice) } }; var moviePriceFactory = new MoviePriceCalculatorFactory(); _movieCatalog = new MovieCatalog(movies, moviePriceFactory); }
/// <summary> /// Helper method to load a JSON file and deserialized to proper structure. NOTE: This is the movie catalog. /// </summary> /// <returns>An object of type MovieCatalog that contains helper information when consumed by third-party.</returns> public MovieCatalog RetriveMovieCatalog() { if (log.IsDebugEnabled) { log.Debug("RetriveMovieCatalog Starts"); } MovieCatalog mc = null; string s; using (StreamReader reader = new StreamReader(catalogNameFileName)) { s = reader.ReadToEnd(); } mc = JsonConvert.DeserializeObject <MovieCatalog>(s); if (log.IsDebugEnabled) { log.Debug("Retrieved Contents=[" + s + "]"); log.Debug("RetriveMovieCatalog Ends"); } return(mc); }
/// <summary> /// The purpose of this page is to service JSON Files. The files are already generated /// elsewhere and are loaded from file system. /// /// A query string parameter is sent to this page. Given name of 'm' and has values of '1:Get movies' file, /// '2:Get Movies Catalog' and so on. /// </summary> /// <param name="m">Which file to get. 1:Movies, 2: Movie Catalog</param> /// <returns></returns> public string RetrieveJSonContentsForModule(string m) { string rslt = ""; MovieCatalog mc = RetriveMovieCatalog(); switch (m) { case "1": rslt = JsonConvert.SerializeObject(RetrieveMovieList()); break; case "2": rslt = JsonConvert.SerializeObject(RetriveMovieCatalog()); break; default: break; } return(rslt); }
/// <summary> /// Given parameters 't:for theater id', 'm:Movie Id', and 'g:Gender id', computes a lookup in the catalog /// matched records. All results must be guaranteed to be sorted. /// </summary> /// <param name="t">Theater Id. Possible value are '-1', or '2'</param> /// <param name="m">Movie Id. Possible value are '-1', or '1|29' this means movieId=1 and movieIdFormat=29</param> /// <param name="g">Gender Id. Possible value are '-1', or '2'</param> /// <returns>A list of 'Movie' objects serialized as JSON. If list is empty, serialized should be empty.</returns> public string Search(string t, string m, string g) { if (log.IsDebugEnabled) { log.Debug("Search Starts"); log.Debug("t=[" + t + "]"); log.Debug("m=[" + m + "]"); log.Debug("g=[" + g + "]"); } int theaterId = Convert.ToInt32(t); int movieId = 0; int movieIdFormat = 0; // Only used where movieId is not set to -1 int genreId = Convert.ToInt32(g); string rslt = ""; // We must split 'm' parameter to its constituent values. // If m = -1", no need to split if (m == "-1") { movieId = Convert.ToInt32(m); } else { var movieValuesArray = m.Split('|'); if (movieValuesArray.Length == 2) { try { movieId = Convert.ToInt32(movieValuesArray[0]); } catch (Exception) { movieId = -1; } movieIdFormat = Convert.ToInt32(movieValuesArray[1]); } else { try { movieId = Convert.ToInt32(movieValuesArray[0]); } catch (Exception) { movieId = -1; } movieIdFormat = -1; } } List <Movie> movieList = RetrieveMovieList(); MovieCatalog mc = RetriveMovieCatalog(); if (theaterId == -1 && movieId == -1 && genreId == -1) { // Retrieves all records. // For the purpose, we need to return Movie objects with its location but not its formats and schedule List <Movie> searchMovieList = new List <Movie>(); movieList.ForEach(FillMovieDataWithoutLocationSchedule(searchMovieList)); searchMovieList = searchMovieList.OrderByDescending(x => x.premiere).ThenBy(x => x.name).ToList <Movie>(); rslt = JsonConvert.SerializeObject(searchMovieList); } else { if (theaterId == -1 && movieId == -1 && genreId != -1) { // Search only by Genre List <Movie> searchMovieList = new List <Movie>(); var movieByGenreList = movieList.Where(x => x.idGenre == genreId).ToList <Movie>(); movieByGenreList.ForEach(FillMovieDataWithoutLocationSchedule(searchMovieList)); searchMovieList = searchMovieList.OrderByDescending(x => x.premiere).ThenBy(x => x.name).ToList <Movie>(); rslt = JsonConvert.SerializeObject(searchMovieList); } else { if (theaterId != -1 && movieId != -1 && genreId == -1) { // Search a specific movie by theater. Any Genre. // No idFormat is required herein. // Select movie and theater. var movieSelected = movieList.Where(x => x.id == movieId).FirstOrDefault <Movie>(); var movieTheaterSelected = movieSelected.locations.Where(x => x.id == theaterId).FirstOrDefault <MovieLocation>(); // Build return movie object Movie movieReturn = new Movie() { id = movieSelected.id, name = movieSelected.name, img = movieSelected.img, url = movieSelected.url, active = movieSelected.active, idGenre = movieSelected.idGenre, genre = movieSelected.genre, premiere = movieSelected.premiere, createDate = movieSelected.createDate }; rslt = JsonConvert.SerializeObject(movieReturn); } else { if (theaterId == -1 && movieId != -1 && genreId == -1) { // Search a movie and give me all the locations for it. // Only one movie must be selected. // Movie record must match criteria for movieId var movieSelected = movieList.Where(x => x.id == movieId).FirstOrDefault <Movie>(); Movie movieReturn = new Movie() { id = movieSelected.id, name = movieSelected.name, img = movieSelected.img, url = movieSelected.url, active = movieSelected.active, idGenre = movieSelected.idGenre, genre = movieSelected.genre, premiere = movieSelected.premiere, createDate = movieSelected.createDate }; // Add the location but without its schedule rslt = JsonConvert.SerializeObject(movieReturn); } else { if (theaterId != -1 && movieId == -1 && genreId == -1) { // Find all movies by given theaterId // Remove duplicates in the process. // This search is best suited by using the MovieCatalog object, as required // objects are compiled to do so. List <Movie> searchMovieList = new List <Movie>(); var theaterInfo = mc.theaters.Where(x => x.id == theaterId).FirstOrDefault <MovieLocationShort>(); if (theaterInfo == null) { // Return nothing as no record is found. rslt = JsonConvert.SerializeObject(searchMovieList); } else { // Retrieve Movie List by theater from theaterMovies var moviesByTheaterList = mc.theaterMovies[theaterInfo.nameFull]; // Compile required information. moviesByTheaterList.ForEach(movie => { // Before creating the movie in 'searchMovieList', it must // be retrived from 'movieList' as 'movie' item is a short version of what // we require. var movieComplete = movieList.Where(x => x.id == movie.id).FirstOrDefault <Movie>(); Movie mv = new Movie() { id = movieComplete.id, name = movieComplete.name, img = movieComplete.img, url = movieComplete.url, active = movieComplete.active, idGenre = movieComplete.idGenre, genre = movieComplete.genre, premiere = movieComplete.premiere, createDate = movieComplete.createDate }; searchMovieList.Add(mv); }); } searchMovieList = searchMovieList.OrderByDescending(x => x.premiere).ThenBy(x => x.name).ToList <Movie>(); rslt = JsonConvert.SerializeObject(searchMovieList); } } } } } if (log.IsDebugEnabled) { log.Debug("Rslt=[" + rslt + "]"); log.Debug("Search Ends"); } return(rslt); }
/// <summary> /// Main method to compute DB records to JSON files. All JSON files are stored in a /// configurable folder. /// </summary> public void CompileAllMoviesSchedule() { if (log.IsDebugEnabled) { log.Debug("CompileAllMoviesSchedule Starts"); log.Debug("Core"); } Pelicula movieDao = new Pelicula(); List <MovieFullInfo> movieFullList = movieDao.updateBillboardAndGetMovieFullInfo(); // Normalize image to conform to URI. movieFullList.ForEach(m => { if (!m.img.Contains("http")) { m.img = imgPathUrl + m.img; } }); // Create List of movies List <Movie> movieList = new List <Movie>(); Movie movieInfo = null; MovieLocation movieLocationInfo = null; MovieFormat movieFormatInfo = null; MovieShow movieShowInfo = null; movieFullList.ForEach(mfInfo => { // Let's first find movie existence var movieExist = movieList.Where(x => x.id == mfInfo.id).FirstOrDefault <Movie>(); if (movieExist != null) { movieInfo = movieExist; } else { movieInfo = new Movie() { id = mfInfo.id, name = mfInfo.name, img = mfInfo.img, url = mfInfo.url, active = mfInfo.active, idGenre = mfInfo.idGenre, genre = mfInfo.genre, premiere = mfInfo.premiere, createDate = mfInfo.createDate, locations = new List <MovieLocation>() }; movieList.Add(movieInfo); } // Fill remaining data for movieInfo record // 1. Fill Location var movieLocationExist = movieInfo.locations.Where(x => x.id == mfInfo.idLocation).FirstOrDefault <MovieLocation>(); if (movieLocationExist != null) { movieLocationInfo = movieLocationExist; } else { movieLocationInfo = new MovieLocation() { id = mfInfo.idLocation, name = mfInfo.nameLocation, branchName = mfInfo.branchName, nameFull = mfInfo.nameFullLocation, address = mfInfo.address, formats = new List <MovieFormat>() }; movieInfo.locations.Add(movieLocationInfo); } // 2. Fill Format var movieFormatExist = movieLocationInfo.formats.Where(x => x.id == mfInfo.idFormat).FirstOrDefault <MovieFormat>(); if (movieFormatExist != null) { movieFormatInfo = movieFormatExist; } else { movieFormatInfo = new MovieFormat() { id = mfInfo.idFormat, name = mfInfo.nameFormat, shows = new List <MovieShow>() }; movieLocationInfo.formats.Add(movieFormatInfo); } // 3. Fill Show var movieShowExist = movieFormatInfo.shows.Where(x => x.id == mfInfo.idShow).FirstOrDefault <MovieShow>(); if (movieShowExist != null) { movieShowInfo = movieShowExist; } else { movieShowInfo = new MovieShow() { id = mfInfo.idShow, dt = mfInfo.dt, hours = movieDao.getMovieShowHoursFor(mfInfo.idShow) }; movieFormatInfo.shows.Add(movieShowInfo); } movieFormatInfo.shows = movieFormatInfo.shows.OrderBy(x => x.dt).ToList <MovieShow>(); }); movieList = movieList.OrderByDescending(x => x.premiere).ThenBy(x => x.name).ToList <Movie>(); // Up to this point we have all movies gathered, now we build the movie Catalog in order // to ease search manipulation when required and to speed data processing. // The following steps must be fullfilled in order to gather all of the movie Catalog. // 1. Load Movie Name list // 2. Movie Formats Name list // 3. Movie Genre Name list // 4. Load all theaters referenced in the schedule. // 5. Load All Theater Name List and its associated movies. // 6. Load Movie Name List and its associated theaters where each movie is being shown. // Let's start. MovieCatalog mc = new MovieCatalog(); mc.theaters = new List <MovieLocationShort>(); mc.formats = new List <MovieFormatShort>(); mc.movies = new List <MovieShortFormat>(); mc.genres = new List <MovieGenreShort>(); // 1. Load Movie Name list movieList.ForEach(movie => { MovieShortFormat movieShort = new MovieShortFormat() { id = movie.id, name = movie.name, premiere = movie.premiere, formats = new List <MovieFormatShort>() }; // Now load formats movie.locations.ForEach(movieLocation => movieLocation.formats.ForEach( movieFormat => { var formatExist = movieShort.formats.Where(x => x.id == movieFormat.id).FirstOrDefault <MovieFormatShort>(); if (formatExist == null) { movieShort.formats.Add(new MovieFormatShort() { id = movieFormat.id, name = movieFormat.name }); } } )); movieShort.formats = movieShort.formats.OrderBy(x => x.name).ToList <MovieFormatShort>(); mc.movies.Add(movieShort); }); mc.movies = mc.movies.OrderBy(x => x.name).ToList <MovieShortFormat>(); // End 1.Load Movie Name List // 2. Movie Formats Name list and 3. Movie Genre Name list and 4. Load all theaters referenced in the schedule. movieFullList.ForEach(movie => { var movieFormatExist = mc.formats.Where(x => x.id == movie.idFormat).FirstOrDefault <MovieFormatShort>(); if (movieFormatExist == null) { mc.formats.Add(new MovieFormatShort() { id = movie.idFormat, name = movie.nameFormat }); } var movieGenreExist = mc.genres.Where(x => x.id == movie.idGenre).FirstOrDefault <MovieGenreShort>(); if (movieGenreExist == null) { mc.genres.Add(new MovieGenreShort() { id = movie.idGenre, name = movie.genre }); } var movieTheaterExist = mc.theaters.Where(x => x.id == movie.idLocation).FirstOrDefault <MovieLocationShort>(); if (movieTheaterExist == null) { mc.theaters.Add(new MovieLocationShort() { id = movie.idLocation, name = movie.nameLocation, branchName = movie.branchName, nameFull = movie.nameFullLocation }); } }); mc.formats = mc.formats.OrderBy(x => x.name).ToList <MovieFormatShort>(); mc.genres = mc.genres.OrderBy(x => x.name).ToList <MovieGenreShort>(); mc.theaters = mc.theaters.OrderBy(x => x.nameFull).ToList <MovieLocationShort>(); // End 2. Movie Formats Name list and 3. Movie Genre Name List and 4. Load all theaters referenced in the schedule. // 5. Load All Theater Name List and its associated movies. // Initialize Dictionary <int, List <MovieLocationShort> > movieInTheaters = new Dictionary <int, List <MovieLocationShort> >(); movieList.ForEach(movie => movieInTheaters.Add(movie.id, new List <MovieLocationShort>())); // Now fill locations per movie. movieList.ForEach(movie => { var movieTheaterSelected = movieInTheaters[movie.id]; movie.locations.ForEach(loc => movieTheaterSelected.Add(new MovieLocationShort() { id = loc.id, name = loc.name, branchName = loc.branchName, nameFull = loc.nameFull })); movieTheaterSelected = movieTheaterSelected.OrderBy(x => x.nameFull).ToList <MovieLocationShort>(); }); // Now store in catalog. mc.movieInTheaters = movieInTheaters; // End 5. Load All Theater Name List and its associated movies. // 6. Load Movie Name List and its associated theaters where each movie is being shown. // Initialize theaterMovies for computation. // Here we use theaterMoviesDictionary temporary variable so in the process it can be build orderd both // its keys and the values it contains. Dictionary <string, List <MovieShortFormat> > theaterMoviesDictionary = new Dictionary <string, List <MovieShortFormat> >(); // Initialize theaterMoviesDictionary with keys ordered by name. List <string> theaterNameList = new List <string>(); mc.theaters.ForEach(t => theaterNameList.Add(t.nameFull)); theaterNameList = theaterNameList.OrderBy(t => t).ToList <string>(); // Now that we have a theaterNameList and ordered, we can now start building the Dictionary values. // Initialize theaterMoviesDictionary dictionary for further processing. theaterNameList.ForEach(t => theaterMoviesDictionary.Add(t, new List <MovieShortFormat>())); // Let's add values to theaterMoviesDictionary movieList.ForEach(movie => { movie.locations.ForEach(location => { // Retrieve theater item from dictionary var theaterItem = theaterMoviesDictionary[location.nameFull]; var existMovie = theaterItem.Where(x => x.id == movie.id).FirstOrDefault <MovieShortFormat>(); if (existMovie == null) { // WARNING!: At this point and supported by mc.movies (which must be already compiled at this point. var movieFormats = mc.movies.Where(x => x.id == movie.id).FirstOrDefault(); theaterItem.Add(new MovieShortFormat() { id = movie.id, premiere = movie.premiere, name = movie.name, formats = movieFormats.formats }); } }); }); // Now it is time to copy contents from theaterMoviesDictionary to mc.theaterMovies // When traversing its contents the list is sorted as well by name. mc.theaterMovies = new Dictionary <string, List <MovieShortFormat> >(); foreach (var pair in theaterMoviesDictionary) { mc.theaterMovies.Add(pair.Key, pair.Value.OrderBy(m => m.name).ToList <MovieShortFormat>()); } // End 6. Load Movie Name List and its associated theaters where each movie is being shown. // Serialize string movieLookupJSON = JsonConvert.SerializeObject(movieList); string movieCatalogJSON = JsonConvert.SerializeObject(mc); // Now that we have just gathered all the information, create static JSON versions // Now there are two files to consume the feed // Full movie catalog (mapped from origin). string fileName = moviesFileName; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieLookupJSON); } fileName = catalogNameFileName; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieCatalogJSON); } if (log.IsDebugEnabled) { log.Debug("Info compiled"); log.Debug("movieLookupJSON=[" + movieLookupJSON + "]"); log.Debug("movieCatalogJSON=[" + movieCatalogJSON + "]"); log.Debug("CompileAllMoviesSchedule Ends"); } }
/// <summary> /// Generates the internal JSON representation to be used internally in EL COLOMBIANO web pages. The topic is the movies category. /// </summary> /// <param name="sender">Sender object which fired the event</param> /// <param name="e">Parameters sent from the event manager.</param> protected void Page_Load(object sender, EventArgs e) { WebClient client = new WebClient(); string url = "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=201&consulta=eventos&bypass=626262"; Stream data = client.OpenRead(url); StreamReader reader = new StreamReader(data); string s = reader.ReadToEnd(); data.Close(); reader.Close(); Response.AddHeader("Access-Control-Allow-Origin", "*"); var movieList = JsonConvert.DeserializeObject <Movie>(s); var movieServiceList = movieList.servicios; foreach (var it in movieServiceList) { it.nombre = it.nombre.Trim(); } var movieListOrdered = movieServiceList.OrderByDescending(x => x.estr).OrderBy(x => x.nombre).ToList(); movieList.servicios = movieListOrdered; List <string> theaterNameList = new List <string>(); movieList.servicios.ForEach(x => x.ptos.Select(y => y.nombre).ToList().ForEach(z => theaterNameList.Add(z))); var theatersList = theaterNameList.Distinct().OrderBy(y => y).ToList(); var genresList = (from service in movieServiceList orderby service.genero select service.genero).Distinct().ToList <String>(); var allMovieNameList = (from service in movieServiceList orderby service.nombre select service.nombre).Distinct().ToList <string>(); MovieCatalog movieCatalog = new MovieCatalog(); movieCatalog.theaters = theatersList; movieCatalog.genres = genresList; movieCatalog.movies = allMovieNameList; Dictionary <string, List <string> > theaterMoviesList = new Dictionary <string, List <string> >(); foreach (var item in movieCatalog.theaters) { List <string> movieNameList = new List <string>(); theaterMoviesList.Add(item, movieNameList); } // Creates now a list of all movies mapped to our structure, given // the Planepoly JSON structure. List <MovieLookup> movieLookupList = new List <MovieLookup>(); foreach (var service in movieList.servicios) { MovieLookup movieLookup = new MovieLookup(); movieLookup.name = service.nombre; movieLookup.img = service.img; movieLookup.url = service.url; movieLookup.premiere = service.estr; movieLookup.genre = service.genero; movieLookup.locations = new List <MovieLookupLocation>(); foreach (var location in service.ptos) { if (theaterMoviesList.ContainsKey(location.nombre)) { var tempList = theaterMoviesList[location.nombre]; tempList.Add(service.nombre); } MovieLookupLocation mlLocation = new MovieLookupLocation(); mlLocation.name = location.nombre; mlLocation.address = location.direccion; List <MovieLookupShow> mlShowList = new List <MovieLookupShow>(); Dictionary <int, string> shows = new Dictionary <int, string>(); shows.Add(0, ""); shows.Add(1, ""); shows.Add(2, ""); shows.Add(3, ""); shows.Add(4, ""); shows.Add(5, ""); shows.Add(6, ""); shows.Add(7, ""); foreach (var show in location.funcs) { if (shows.ContainsKey(show.dia)) { var valDay = shows[show.dia]; valDay += show.hora + " "; shows[show.dia] = valDay; } } foreach (var it in shows) { if (it.Value.Trim() != "") { MovieLookupShow mls = new MovieLookupShow(); mls.frequency = it.Key; mls.hours = it.Value.Trim(); switch (mls.frequency) { case 0: mls.name = "Diario"; break; case 1: mls.name = "Lunes"; break; case 2: mls.name = "Martes"; break; case 3: mls.name = "Miércoles"; break; case 4: mls.name = "Jueves"; break; case 5: mls.name = "Viernes"; break; case 6: mls.name = "Sábado"; break; case 7: mls.name = "Domingo"; break; default: break; } mlShowList.Add(mls); } } mlLocation.schedule = mlShowList; movieLookup.locations.Add(mlLocation); } movieLookupList.Add(movieLookup); } foreach (var it in theaterMoviesList) { it.Value.Sort(); } movieCatalog.theaterMovies = theaterMoviesList; var movieLookupListOrdered = (from item in movieLookupList orderby item.premiere descending, item.name select item).ToList(); string movieCatalogJSON = JsonConvert.SerializeObject(movieCatalog); string movieLookupJSON = JsonConvert.SerializeObject(movieLookupListOrdered); // Now that we have just gathered all the information, create static JSON versions // Now there are two files to consume the feed // Full movie (mapped from origin). string fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieLookupJSON); } // Full movie catalog (mapped from origin) fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies-catalog.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieCatalogJSON); } // This is the page result. Response.Write(movieLookupJSON); }
public MovieController(MovieCatalog mc, ClientStore cs) { _mc = mc; _cs = cs; }
public DomainModel(bool loadTestData = false) { Cars = new CarCatalog(loadTestData); Movies = new MovieCatalog(loadTestData); }
/// <summary> /// Main method to compute DB records to JSON files. All JSON files are stored in a /// configurable folder. /// </summary> public void CompileAllMoviesSchedule() { string sql = ""; MovieCatalog mc = new MovieCatalog(); mc.theaters = new List <MovieTheaterInfo>(); mc.formats = new List <MovieFormatInfo>(); mc.movies = new List <MovieShortInfo>(); mc.theaterMovies = new Dictionary <string, List <MovieShortInfo> >(); sql += "select * from vw_datospelicula "; sql += "where activo = 'S' "; sql += "order by idPelicula, idTeatro, frecuencia, idformato "; List <MovieLookup> movieList = new List <MovieLookup>(); HandleDatabase hdb = new HandleDatabase(dbConnection); hdb.Open(); SqlTransaction transaction = hdb.BeginTransaction("CompileAllMoviesSchedule"); SqlDataReader rdr = hdb.ExecSelectSQLStmtAsReader(transaction, sql); int oldMovie = -1; int newMovie = 0; int oldTheater = -1; int newTheater = 0; int oldFormat = -1; int newFormat = 0; bool doMovieRecord = false; MovieLookup m = null; MovieLookupLocation movieLocation = null; while (rdr.Read()) { newMovie = Convert.ToInt32(rdr["idPelicula"]); newFormat = Convert.ToInt32(rdr["idFormato"]); if (oldMovie != newMovie) { // Create Movie detail when movie break control is met. oldMovie = newMovie; oldFormat = newFormat; doMovieRecord = true; } else { if (oldFormat != newFormat) { oldFormat = newFormat; doMovieRecord = true; } } if (doMovieRecord) { doMovieRecord = false; oldTheater = -1; m = new MovieLookup(); m.id = newMovie; m.name = rdr["nombrePelicula"].ToString(); m.idFormat = newFormat; m.format = rdr["nombreFormato"].ToString(); m.nameFull = m.name + " " + m.format; m.img = rdr["imagenCartelera"].ToString(); m.url = rdr["urlArticuloEC"].ToString(); m.active = rdr["activo"].ToString(); m.idGenre = Convert.ToInt32(rdr["idGeneroPelicula"]); m.genre = rdr["nombreGenero"].ToString(); movieList.Add(m); m.locations = new List <MovieLookupLocation>(); } newTheater = Convert.ToInt32(rdr["idTeatro"]); if (oldTheater != newTheater) { oldTheater = newTheater; movieLocation = new MovieLookupLocation(); movieLocation.schedule = new List <MovieLookupShow>(); movieLocation.id = newTheater; movieLocation.name = rdr["nombreCine"].ToString(); movieLocation.branchName = rdr["nombreTeatro"].ToString(); movieLocation.nameFull = movieLocation.name + " " + movieLocation.branchName; movieLocation.address = rdr["direccionTeatro"].ToString(); m.locations.Add(movieLocation); } // Now Load Location Hours MovieLookupShow mls = new MovieLookupShow(); mls.id = Convert.ToInt32(rdr["idHorarioPelicula"]); mls.frequency = Convert.ToInt32(rdr["frecuencia"]); mls.name = rdr["nombreDiaSemanaHorarioPelicula"].ToString(); mls.year = Convert.ToInt32(rdr["annoHorarioPelicula"]); mls.month = Convert.ToInt32(rdr["mesHorarioPelicula"]); mls.day = Convert.ToInt32(rdr["diaHorarioPelicula"]); mls.hours = LoadHoursFor(mls.id); movieLocation.schedule.Add(mls); } rdr.Close(); transaction.Commit(); hdb.Close(); // Up to this point we have all movies gathered, now we build the movie Catalog in order // to ease search manipulation when required and to speed data processing. // 1. Load Movie Name list var movieNameList = (from it in movieList orderby it.active descending, it.nameFull select new MovieShortInfo() { id = it.id, idFormat = it.idFormat, name = it.name, nameFull = it.nameFull }).ToList <MovieShortInfo>(); mc.movies = movieNameList; // 2. Movie Formats Name list var movieFormatNameList = (from it in movieList orderby it.format select new MovieFormatInfo() { id = it.idFormat, name = it.format } ).ToList <MovieFormatInfo>(); List <MovieFormatInfo> formatListFiltered = new List <MovieFormatInfo>(); oldFormat = -1; newFormat = 0; foreach (var item in movieFormatNameList) { newFormat = item.id; if (oldFormat != newFormat) { oldFormat = newFormat; formatListFiltered.Add(new MovieFormatInfo() { id = item.id, name = item.name }); } } mc.formats = formatListFiltered; // 3. Movie Genre Name list var movieGenreNameList = (from it in movieList orderby it.genre select new MovieGenreInfo { id = it.idGenre, name = it.genre }).ToList <MovieGenreInfo>(); List <MovieGenreInfo> genreListFiltered = new List <MovieGenreInfo>(); int oldGenre = -1; int newGenre = 0; foreach (var item in movieGenreNameList) { newGenre = item.id; if (oldGenre != newGenre) { oldGenre = newGenre; genreListFiltered.Add(new MovieGenreInfo() { id = item.id, name = item.name }); } } mc.genres = genreListFiltered; // 4. Load all theaters referenced in the schedule. foreach (var movieItem in movieList) { foreach (var loc in movieItem.locations) { MovieTheaterInfo mti = new MovieTheaterInfo(); mti.id = loc.id; mti.name = loc.name; mti.branchName = loc.branchName; mti.nameFull = loc.nameFull; mc.theaters.Add(mti); } } // Lets order by id mc.theaters = (from t in mc.theaters orderby t.id select t).ToList <MovieTheaterInfo>(); // We now have theater names, but not sorted and not distinct. Let's sort by name excluding repeated. List <MovieTheaterInfo> allTheatersDistinctList = new List <MovieTheaterInfo>(); oldTheater = -1; newTheater = 0; foreach (var t in mc.theaters) { newTheater = t.id; if (oldTheater != newTheater) { MovieTheaterInfo mti = new MovieTheaterInfo(); mti.id = t.id; mti.name = t.name; mti.branchName = t.branchName; mti.nameFull = t.nameFull; allTheatersDistinctList.Add(mti); oldTheater = newTheater; } } // Now list has all distinct IDs, now let's sort by name mc.theaters = (from t in allTheatersDistinctList orderby t.nameFull select t).Distinct().ToList <MovieTheaterInfo>(); // 5. Load Movie Name List and its associated theaters where each movie is being shown. Dictionary <string, List <MovieShortInfo> > theaterMovies = new Dictionary <string, List <MovieShortInfo> >(); // Initialize theaterMovies for computation. mc.theaters.ForEach(t => theaterMovies.Add(t.nameFull, new List <MovieShortInfo>())); foreach (var movieItem in movieList) { int currentMovieId = movieItem.id; foreach (var loc in movieItem.locations) { var theaterItem = theaterMovies[loc.nameFull]; bool movieExists = false; foreach (var movieShortInfo in theaterItem) { if (movieShortInfo.id == currentMovieId) { movieExists = true; break; } } if (!movieExists) { theaterItem.Add(new MovieShortInfo() { id = currentMovieId, idFormat = movieItem.idFormat, name = movieItem.name, nameFull = movieItem.nameFull }); } } } mc.theaterMovies = theaterMovies; // Serialize string movieLookupJSON = JsonConvert.SerializeObject(movieList); string movieCatalogJSON = JsonConvert.SerializeObject(mc); // Now that we have just gathered all the information, create static JSON versions // Now there are two files to consume the feed // Full movie catalog (mapped from origin). string fileName = moviesFileName; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieLookupJSON); } fileName = catalogNameFileName; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieCatalogJSON); } }
// Parameter in URL are // m: Movie id. // f: Movie Format id. // t: Theater id. protected void Page_Load(object sender, EventArgs e) { // Load parameters. m = Request.QueryString["m"]; t = Request.QueryString["t"]; f = Request.QueryString["f"]; // Let's compute parameters as true integers. int tst = 0; if (m == null) { m = "0"; } else { try { tst = Convert.ToInt32(m); } catch (Exception) { m = "0"; } } if (t == null) { t = "-1"; } else { try { tst = Convert.ToInt32(t); if (tst == 0) { t = "-1"; } } catch (Exception) { t = "-1"; } } if (f == null) { f = "-1"; } else { try { tst = Convert.ToInt32(f); if (tst == 0) { f = "-1"; } } catch (Exception) { f = "-1"; } } ManageMovieCatalog mmc = new ManageMovieCatalog(Settings.JSONFolder + @"\" + Settings.FileMovieCatalog, Settings.JSONFolder + @"\" + Settings.FileMovies, ""); int movieId = Convert.ToInt32(m); movieList = mmc.RetrieveMovieList(); mc = mmc.RetriveMovieCatalog(); movieToShow = movieList.Where(x => x.id == movieId).FirstOrDefault <Movie>(); movieID.Value = m; if (!IsPostBack) { LoadData(); LoadDetailedData(); } }
private DomainModel() { Movies = new MovieCatalog(); Screens = new ScreenCatalog(); Shows = new ShowCatalog(); }