public async Task GetCinemas() { var allCinemas = await _cinemasAPI.Get <List <Model.Cinema> >(null); allCinemas.Sort((a, b) => a.Name.CompareTo(b.Name)); if (SelectedLocation != null) { Model.Requests.CinemasSearchRequest search = new Model.Requests.CinemasSearchRequest() { Location = SelectedLocation }; var c = new List <Model.Cinema>(); if (SelectedLocation == "All") { c = await _cinemasAPI.Get <List <Model.Cinema> >(null); } else { c = await _cinemasAPI.Get <List <Model.Cinema> >(search); } c.Sort((a, b) => a.Name.CompareTo(b.Name)); Cinemas.Clear(); foreach (var cinema in c) { Cinemas.Add(cinema); } } if (Locations.Count == 0) { var list = new List <string>(); list.Add("All"); foreach (var cinema in allCinemas) { list.Add(cinema.Location); } list = list.Distinct().ToList(); list.Sort(); foreach (var location in list) { Locations.Add(location); } } }
public void RefreshVMs() { var selection = repo.GetAll(); Cinemas.Clear(); Movies.Clear(); Shows.Clear(); Bookings.Clear(); if (LockedCinema != null) { Cinemas.Add(new CinemaVM { Cinema = LockedCinema.Cinema, Town = LockedCinema.Town, Locked = true }); selection = selection.Where(sb => LockedCinema.Cinema == sb.CinemaName && LockedCinema.Town == sb.CinemaTown); } if (LockedMovie != null) { Movies.Add(new MovieVM { Title = LockedMovie.Title, Genre = LockedMovie.Genre, Duration = LockedMovie.Duration, Director = LockedMovie.Director, ReleaseDate = LockedMovie.ReleaseDate, Locked = true }); selection = selection.Where(sb => LockedMovie.Title == sb.MovieTitle && LockedMovie.Duration == sb.MovieDuration && LockedMovie.Director == sb.MovieDirector && LockedMovie.Genre == sb.MovieGenre); } if (LockedShow != null) { Shows.Add(new ShowVM { ShowDateTime = LockedShow.ShowDateTime, Locked = true }); selection = selection.Where(sb => LockedShow.ShowDateTime == sb.ShowDateTime); } if (LockedBooking != null) { Bookings.Add(new BookingVM { BookingMail = LockedBooking.BookingMail, BookingPhone = LockedBooking.BookingPhone, Locked = true }); selection = selection.Where(sb => LockedBooking.BookingMail == sb.BookingMail && LockedBooking.BookingPhone == sb.BookingPhone); } foreach (CinemaMovieShowBooking sb in selection) { if (sb.CinemaName != default && sb.CinemaTown != default) { if (LockedCinema == null) { if (Cinemas.Where(c => c.Cinema == sb.CinemaName && c.Town == sb.CinemaTown).Count() == 0) { Cinemas.Add(new CinemaVM { Cinema = sb.CinemaName, Town = sb.CinemaTown, Locked = false }); } } } if (sb.MovieTitle != default && sb.MovieGenre != default && sb.MovieDirector != default && sb.MovieDuration != default && sb.MovieReleaseDate != default) { if (LockedMovie == null) { if (Movies.Where(m => m.Title == sb.MovieTitle && m.Duration == sb.MovieDuration && m.Director == sb.MovieDirector && m.Genre == sb.MovieGenre).Count() == 0) { Movies.Add(new MovieVM { Title = sb.MovieTitle, Genre = sb.MovieGenre, Duration = sb.MovieDuration, Director = sb.MovieDirector, ReleaseDate = sb.MovieReleaseDate, Locked = false }); } } } if (sb.ShowDateTime != default) { if (LockedShow == null) { if (Shows.Where(s => s.ShowDateTime == sb.ShowDateTime).Count() == 0) { Shows.Add(new ShowVM { ShowDateTime = sb.ShowDateTime, Locked = false }); } } } if (sb.BookingMail != default && sb.BookingPhone != default) { if (LockedBooking == null) { if (Bookings.Where(b => b.BookingMail == sb.BookingMail && b.BookingPhone == sb.BookingPhone).Count() == 0) { Bookings.Add(new BookingVM { BookingMail = sb.BookingMail, BookingPhone = sb.BookingPhone, Locked = false }); } } } } }