Exemplo n.º 1
0
        public IActionResult CinemaCreate(string Address, string city, string CinemaName)
        {
            var CinemaLocation = new CinemaLocation()
            {
                Address     = Address,
                CinemaHalls = new List <CinemaHall>(),
                CinemaName  = CinemaName,
                FoodAmounts = new List <FoodAmount>()
            };
            var City = cityService.Get().Find(a => a.CityName == city);

            if (City != null)
            {
                CinemaLocation.CityId = City.Id;
                CinemaLocation.City   = City;
            }
            else
            {
                City = cityService.Add(new City()
                {
                    CityName = city
                });
                CinemaLocation.CityId = City.Id;
                CinemaLocation.City   = City;
            }
            cinemaLocationService.Add(CinemaLocation);
            return(RedirectToAction("CinemaLocationTable"));
        }
Exemplo n.º 2
0
        public IActionResult DeleteConfirmed(int id)
        {
            CinemaLocation cinemaLocation = _context.CinemaLocation.Single(m => m.ID == id);

            _context.CinemaLocation.Remove(cinemaLocation);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public int GetLocationIdByName(string locationName)
        {
            CinemaLocation location = _cinemaDbContext.CinemaLocations.FirstOrDefault(x => x.NameLocation == locationName);

            if (location == null)
            {
                return(0);
            }
            return(location.LocationId);
        }
Exemplo n.º 4
0
 public IActionResult Edit(CinemaLocation cinemaLocation)
 {
     if (ModelState.IsValid)
     {
         _context.Update(cinemaLocation);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cinemaLocation));
 }
Exemplo n.º 5
0
        public CinemaLocationDTO GetLocationById(int cinemaLocationId)
        {
            CinemaLocation locationFromDb = _cinemaDbContext.CinemaLocations.FirstOrDefault(x => x.LocationId == cinemaLocationId);

            if (locationFromDb == null)
            {
                return(null);
            }
            return(new CinemaLocationDTO {
                LocationId = locationFromDb.LocationId,
                AddressLocation = locationFromDb.AddressLocation,
                NameLocation = locationFromDb.NameLocation,
            });
        }
Exemplo n.º 6
0
        // GET: CinemaLocations/Edit/5
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            CinemaLocation cinemaLocation = _context.CinemaLocation.Single(m => m.ID == id);

            if (cinemaLocation == null)
            {
                return(HttpNotFound());
            }
            return(View(cinemaLocation));
        }
        /// <summary>
        /// Method deserialize JSON and save cinemas locations to list.
        /// </summary>
        /// <returns>Return alphabetically sorted list</returns>
        public List <string> Execute()
        {
            CinemaIdJSONFileSource cinemaLocation        = new CinemaIdJSONFileSource();
            CinemaLocation         venues                = cinemaLocation.GetJson();
            List <string>          listOfCinemaLocations = new List <string>();

            foreach (var venue in venues.Venues)
            {
                foreach (var cinema in venue.Cinemas)
                {
                    listOfCinemaLocations.Add(cinema.Search);
                }
            }
            listOfCinemaLocations.Sort();

            return(listOfCinemaLocations);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Method deserialize JSON with CinemaIdJSONFileSource class.
        /// </summary>
        /// <returns>Return string with cinema list splited by ", "</returns>
        public string Execute()
        {
            CinemaIdJSONFileSource cinemaLocation = new CinemaIdJSONFileSource();
            CinemaLocation         venues         = cinemaLocation.GetJson();
            StringBuilder          cinemaList     = new StringBuilder();

            foreach (var venue in venues.Venues)
            {
                foreach (var cinema in venue.Cinemas)
                {
                    cinemaList.Append(cinema.Search + ",");
                }
            }


            return(cinemaList.ToString());
        }
Exemplo n.º 9
0
        public List <CinemaBroadcastDTO> GetBroadcastsByMovieIdAndLocationName(int id, string locationName)
        {
            CinemaLocation location = _cinemaDbContext.CinemaLocations.FirstOrDefault(x => x.NameLocation == locationName);

            if (location == null)
            {
                return(null);
            }
            List <CinemaBroadcastDTO> broadcastsFromDb = _cinemaDbContext.CinemaBroadcasts
                                                         .Where(x => x.MovieId == id && x.CinemaLocationId == location.LocationId)
                                                         .Select(x => new CinemaBroadcastDTO {
                BroadcastId      = x.BroadcastId,
                CinemaLocationId = x.CinemaLocationId,
                MovieId          = x.MovieId,
                PriceId          = x.PriceId,
                Time             = x.BroadcastTime,
                BroadcastTime    = x.BroadcastTimeHour,
                NumberOfSeats    = x.NumberOfSeats
            }).ToList();

            return(broadcastsFromDb);
        }