public async Task <CinemaDetails> GetCinema(string name) { CinemaDetails cinema = _cacheService.Get <CinemaDetails>(name); if (cinema == null) { if (_connectivity.EnsureInternetAccess()) { var uri = ResourceIdentifier.CinemasUri(); try { var responseString = await _httpService.Get(uri); var cinemas = (List <CinemaDetails>)_jsonConverter.DeserializeObject(responseString, typeof(List <CinemaDetails>)); var query = (from c in cinemas where (c.Name + " " + c.City).Equals(name) select c); cinema = query.First(); _cacheService.Set(name, cinema, CacheExpiry(15.0)); } catch { ShowGetFailedNotification(); return(new CinemaDetails()); } } else { ShowConnectionNotification(); return(new CinemaDetails()); } } return(cinema); }
public MovieViewModel(IDataStorage dataStorage, MovieShows movieShow) { _dataStorage = dataStorage; _cinema = Task.Run(() => _dataStorage.GetCinema(movieShow.Cinema)).Result; Genres = movieShow.Genres; Shows = movieShow.Shows; var movie = Task.Run(() => _dataStorage.GetMovie(movieShow.MovieId)).Result; var ratings = Task.Run(() => _dataStorage.GetRating(movieShow.CinemaId, movieShow.MovieId)).Result; foreach (var rating in ratings) { CleanlinessRating += rating.Cleanliness; ScreenRating += rating.Screen; SeatsRating += rating.Comfort; SnacksRating += rating.Snacks; SoundRating += rating.Sound; } CleanlinessRating = CleanlinessRating / ratings.Count; ScreenRating /= ratings.Count; SeatsRating /= ratings.Count; SnacksRating /= ratings.Count; SoundRating /= ratings.Count; AverageRating = (CleanlinessRating + ScreenRating + SeatsRating + SnacksRating + SoundRating) / 5; Cast = movie.Cast; Description = movie.Storyline; Director = movie.Director; Title = movie.OriginalName; OpenWebsite = new Command(VisitWebsite); OpenYoutube = new Command(VisitYoutube); }
public Movie GetMovieShowDetailsById(int movieId, short cityId) { TimeSpan duration; List <SqlParameter> param = new List <SqlParameter>(); param.Add(new SqlParameter() { ParameterName = "@MovieId", Value = movieId }); param.Add(new SqlParameter() { ParameterName = "@CityId", Value = movieId }); DataSet ds = Select(StoredProcedureName.GET_MOVIE_SHOW_BY_ID, param); Movie movie = null; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; TimeSpan.TryParse(row["Duration"].ToStringSafe(), out duration); List <Movie> movieList = ds.Tables[0].ConvertToList <Movie>(); movie = movieList.FirstOrDefault(); List <CinemaDetails> cinemaList = null; if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0) { cinemaList = new List <CinemaDetails>(); foreach (DataRow currentCinema in ds.Tables[1].Rows) { int cinemaId = currentCinema["CinemaId"].ToIntSafe(); if (cinemaList.Select(c => c.CinemaId).Contains(cinemaId)) { continue; } string cinemaName = currentCinema["CinemaName"].ToStringSafe(); CinemaDetails cinema = new CinemaDetails { CinemaId = cinemaId, CinemaName = cinemaName }; string filter = "CinemaId=" + currentCinema["CinemaId"].ToString(); cinema.ShowList = ds.Tables[1].Select(filter).ConvertToList <ShowDetails>(); cinemaList.Add(cinema); } } if (cinemaList != null) { movie.CinemaList = cinemaList; } } return(movie); }
public void Senior_Test() { //Arrange int quantity = 2; string person = "senior"; double expected = 25; //Act CinemaDetails cin1 = new CinemaDetails(); cin1.Senior_price(quantity, person); //Assert double total_price = quantity * cin1.senior_price; Assert.AreEqual(expected, total_price, 12.5, "passed"); }
public void Child_Test() { //Arrange int quantity = 4; string person = "child"; double expected = 48; //Act CinemaDetails cin1 = new CinemaDetails(); cin1.Child_price(quantity, person); //Assert double total_price = quantity * cin1.child_price; Assert.AreEqual(expected, total_price, 12, "Passed"); }
public void Family_test() { //Arrange int quantity = 2; string person = "family"; double expected = 92; //Act CinemaDetails Cin1 = new CinemaDetails(); Cin1.Family_price(quantity, person); //Assert double total_price = quantity * Cin1.family_price; Assert.AreEqual(expected, total_price, 92, "Passed"); }
public void Student_Test() { //Arrange int quantity = 3; string person = "student"; double expected = 42; //Act CinemaDetails cin1 = new CinemaDetails(); cin1.Student_price(quantity, person); //Assert double total_price = quantity * cin1.student_price; Assert.AreEqual(expected, total_price, 14, "passed"); }
public void Adult_tuesday_Test() { //Arrange int quantity = 3; string person = "adult"; string day = "Tuesday"; double expected = 39; //Act CinemaDetails Cin1 = new CinemaDetails(); Cin1.Adult_tuesday(quantity, person, day); //Assert double total_price = quantity * Cin1.adult_tuesday_price; Assert.AreEqual(expected, total_price, 13, "Passed"); }
public void Kids_and_carers() { //Arrange int quantity = 2; string person = "Kids and carers"; string day = "Wedndesday"; double expected = 24; //Act CinemaDetails Cin1 = new CinemaDetails(); Cin1.Kids_and_carers_price(quantity, person, day); //Assert double total_price = quantity * Cin1.kids_and_carers_price; Assert.AreEqual(expected, total_price, 25, "Passed"); }
public void Chick_flick_thursdays_test() { //Arrange int quantity = 2; string person = "Chick"; string day = "Thursdays"; double expected = 43; //Act CinemaDetails Cin1 = new CinemaDetails(); Cin1.Chick_flick_thursdays_price(quantity, person, day); //Assert double total_price = quantity * Cin1.chick_flick_thursdays_price; Assert.AreEqual(expected, total_price, 43, "Passed"); }
public void Adult_after_5pm_Test() { //Arrange int quantity = 2; string person = "adult"; string day = "true"; int time = 0600; double expected = 35.0; //Act CinemaDetails Cin1 = new CinemaDetails(); Cin1.Adult_after_5pm(quantity, person, day, time); //Assert double total_price = quantity * Cin1.adult_after_5_price; Assert.AreEqual(expected, total_price, 17.5, "Passed"); }
public Shows GetShowDetailsByCriteria(int movieId, short cityId, DateTime fromDate, DateTime toDate) { List <SqlParameter> param = new List <SqlParameter>(); param.Add(new SqlParameter() { ParameterName = "@MovieId", Value = movieId }); param.Add(new SqlParameter() { ParameterName = "@CityId", Value = cityId }); param.Add(new SqlParameter() { ParameterName = "@FromDate", Value = fromDate }); param.Add(new SqlParameter() { ParameterName = "@ToDate", Value = toDate }); DataSet ds = Select(StoredProcedureName.GET_SHOW_LIST, param); Shows showDetails = new Shows(); List <DayWiseShowDetails> showList = new List <DayWiseShowDetails>(); List <CinemaDetails> cinemaList = null; DateTime currentDate = fromDate; int cinemaId = 0; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { while (currentDate <= toDate) { DayWiseShowDetails currentDayDetails = new DayWiseShowDetails(); currentDayDetails.ShowDate = currentDate; cinemaList = new List <CinemaDetails>(); foreach (DataRow currentCinema in ds.Tables[0].Rows) { if (Convert.ToDateTime(currentCinema["ShowDate"]).ToShortDateString() == currentDate.ToShortDateString()) { cinemaId = currentCinema["CinemaId"].ToIntSafe(); if (cinemaList.Select(c => c.CinemaId).Contains(cinemaId)) { continue; } string cinemaName = currentCinema["CinemaName"].ToStringSafe(); CinemaDetails cinema = new CinemaDetails { CinemaId = cinemaId, CinemaName = cinemaName }; string filter = "CinemaId=" + currentCinema["CinemaId"].ToString() + " and " + "ShowDate='" + currentDayDetails.ShowDate + "'"; cinema.ShowList = ds.Tables[0].Select(filter).ConvertToList <ShowDetails>(); cinemaList.Add(cinema); } } if (cinemaList != null) { currentDayDetails.CinemaList = cinemaList; } showList.Add(currentDayDetails); TimeSpan duration = new TimeSpan(1, 0, 0, 0); currentDate = currentDate.Add(duration); } } if (showList != null) { showDetails.ShowList = showList; } return(showDetails); }