public static List <Booking> GetAll() { try { string data = Path.Booking; if (!File.Exists(Path.Booking)) { return(new List <Booking>()); } DataSet ds = new DataSet(); ds.ReadXml(data); var bookings = new List <Booking>(); bookings = (from rows in ds.Tables[0].AsEnumerable() select new Booking { Id = Guid.Parse(rows[0].ToString()), UserId = Guid.Parse(rows[1].ToString()), MovieId = Guid.Parse(rows[2].ToString()), CinemaId = Guid.Parse(rows[3].ToString()), Price = Decimal.Parse(rows[4].ToString()), BookingDate = DateTime.ParseExact(rows[5].ToString(), "dd/MM/yyyy", null), User = new Lazy <User>(() => { return(Users.Get(Guid.Parse(rows[1].ToString()))); }), Movie = new Lazy <Movie>(() => { return(Movies.Get(Guid.Parse(rows[2].ToString()))); }), Cinema = new Lazy <Cinema>(() => { return(Cinemas.Get(Guid.Parse(rows[3].ToString()))); }) }).ToList(); if (bookings == null) { return(new List <Booking>()); } return(bookings); } catch { return(new List <Booking>()); } }
public static List <CinemaAmenity> GetAll() { try { string data = Path.CinemaAmenity; if (!File.Exists(Path.CinemaAmenity)) { return(new List <CinemaAmenity>()); } DataSet ds = new DataSet(); ds.ReadXml(data); var CinemaAmenities = new List <CinemaAmenity>(); CinemaAmenities = (from rows in ds.Tables[0].AsEnumerable() select new CinemaAmenity { Id = Guid.Parse(rows[0].ToString()), CinemaId = Guid.Parse(rows[1].ToString()), AmenityId = Guid.Parse(rows[2].ToString()), Cinema = new Lazy <Cinema>(() => { return(Cinemas.Get(Guid.Parse(rows[1].ToString()))); }), Amenity = new Lazy <Amenity>(() => { return(Amenities.Get(Guid.Parse(rows[2].ToString()))); }) }).ToList(); if (CinemaAmenities == null) { return(new List <CinemaAmenity>()); } return(CinemaAmenities); } catch { return(new List <CinemaAmenity>()); } }