Esempio n. 1
0
        //Method that gets the theaters by City
        public IList <UserTheaterDTO> GetTheatersByCity(String City, int movieID)
        {
            IList <UserTheaterDTO> ListOfTheaters = new List <UserTheaterDTO>();

            using (var context = new CinemaEntities())
            {
                var results = (from pr in context.Perfomances.Include("Theater")
                               join ad in context.Addresses.Include("ObjectType")
                               on pr.TheaterID equals ad.ObjectID
                               where pr.MovieID == movieID
                               where ad.City == City
                               where ad.ObjectType.Description == "Theater"
                               select new
                {
                    TheaterID = pr.TheaterID,
                    TheaterName = pr.Theater.Name,
                    AddressTh = ad
                });
                if (results != null)
                {
                    foreach (var item in results)
                    {
                        UserTheaterDTO row = new UserTheaterDTO();
                        row.TheaterID      = item.TheaterID;
                        row.TheaterName    = item.TheaterName;
                        row.TheaterAddress = String.Format("str. {0}, {1}, phone number: {2}.", item.AddressTh.AddressLine1, item.AddressTh.City, item.AddressTh.Phone);
                        ListOfTheaters.Add(row);
                    }
                }
            }
            return(ListOfTheaters);
        }
Esempio n. 2
0
        //Method that gets the theaters by City
        public IList<UserTheaterDTO> GetTheatersByCity(String City, int movieID)
        {
            IList<UserTheaterDTO> ListOfTheaters = new List<UserTheaterDTO>();
            using (var context = new CinemaEntities())
            {
                var results = (from pr in context.Perfomances.Include("Theater")
                               join ad in context.Addresses.Include("ObjectType")
                               on pr.TheaterID equals ad.ObjectID
                               where pr.MovieID == movieID
                               where ad.City == City
                               where ad.ObjectType.Description == "Theater"
                               select new
                               {
                                   TheaterID = pr.TheaterID,
                                   TheaterName = pr.Theater.Name,
                                   AddressTh = ad
                               });
                if (results != null)
                {
                    foreach (var item in results)
                    {
                        UserTheaterDTO row = new UserTheaterDTO();
                        row.TheaterID = item.TheaterID;
                        row.TheaterName = item.TheaterName;
                        row.TheaterAddress = String.Format("str. {0}, {1}, phone number: {2}.", item.AddressTh.AddressLine1, item.AddressTh.City, item.AddressTh.Phone);
                        ListOfTheaters.Add(row);
                    }
                }

            }
            return ListOfTheaters;
        }