Beispiel #1
0
        public List <Cinemas> getCinemas()
        {
            int    id;
            string nome;
            string query = "SELECT id,nome from cinemas";

            List <string> columnas = new List <string>();

            columnas.Add("id");
            columnas.Add("nome");

            List <string>[] data = Select(query, 2, columnas);

            List <Cinemas> cinemas = new List <Cinemas>();


            for (int i = 0; i < data[0].Count(); i++)
            {
                id   = Convert.ToInt32(data[0][i]);
                nome = data[1][i];
                Cinemas newCinema = new Cinemas(id, nome);
                cinemas.Add(newCinema);
            }
            return(cinemas);
        }
Beispiel #2
0
 public CinemasVM(Cinemas cinemas)
 {
     CinemaId   = cinemas.Id;
     CinemaName = cinemas.CinemaName;
     Address    = cinemas.Address;
     CountSeats = cinemas.CountSeats;
 }
Beispiel #3
0
        public async Task <IHttpActionResult> PutCinemas(int id, Cinemas cinemas)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cinemas.id)
            {
                return(BadRequest());
            }

            db.Entry(cinemas).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CinemasExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult <Cinemas> > PostCinema([FromForm] string Name, [FromForm] string Location, [FromForm] string City, [FromForm] int Capacity)
        {
            try
            {
                Cinemas cinema = new Cinemas
                {
                    Name     = Name,
                    Location = Location,
                    Capacity = Capacity,
                    City     = City
                };

                _context.Cinema.Add(cinema);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                return(BadRequest("Já existe um cinema com esse nome."));
            }
            catch (Exception)
            {
                return(BadRequest("Erro inesperado."));
            }
            return(StatusCode(201));
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Cinemas cinemas = db.Cinemas.Find(id);

            db.Cinemas.Remove(cinemas);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public CinemasVM FindById(int cId)
        {
            Cinemas f = _unitOfWork.Cinemas.Get(cId);

            return(new CinemasVM {
                Id = f.Id, Name = f.Name, City = f.City, Address = f.Address
            });
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Cinemas cinemas = await db.Cinemas.FindAsync(id);

            db.Cinemas.Remove(cinemas);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public List <Movie> GetAllMovies(string userChoice)
        {
            List <Movie> movies = Cinemas
                                  .Where(c => c.Name == userChoice)
                                  .SelectMany(m => m.Movies)
                                  .ToList();

            return(movies);
        }
Beispiel #9
0
        public IActionResult PostCinema([FromBody] Cinemas cinemas)
        {
            if (cinemas == null)
            {
                return(BadRequest());
            }
            _cinemaService.CreateCinema(cinemas);

            return(Ok(cinemas));
        }
        public static List <MovieHall> GetMovieHallsByCinemaId(int cinemaId)
        {
            var cinema = Cinemas.SingleOrDefault(x => x.ID == cinemaId);

            if (cinema == null)
            {
                return(new List <MovieHall>());
            }
            return(cinema.MovieHalls);
        }
        public void AddCinema(Cinemas cinema)
        {
            Cinemas cinemas = new Cinemas();

            cinemas.Name       = cinema.Name;
            cinemas.City       = cinema.City;
            cinemas.Address    = cinema.Address;
            cinemas.CountSeats = cinema.CountSeats;
            _unitOfWork.Cinemas.Create(cinemas);
        }
Beispiel #12
0
 public ActionResult Edit([Bind(Include = "Id,CinemaName,Halls,ContactNumber,TicketFee,isGoogleMapApiActive,SeatsAvailable,StaticLocation,latitude,longitude")] Cinemas cinemas)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cinemas).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cinemas));
 }
Beispiel #13
0
        public async Task <ActionResult> PostCinemas(Cinemas cinemas)
        {
            if (cinemas == null)
            {
                return(BadRequest());
            }
            await Task.Run(() => _cinemasService.AddCinema(cinemas));

            return(Ok(cinemas));
        }
Beispiel #14
0
        public async Task <IHttpActionResult> GetCinemas(int id)
        {
            Cinemas cinemas = await db.Cinemas.FindAsync(id);

            if (cinemas == null)
            {
                return(NotFound());
            }

            return(Ok(cinemas));
        }
Beispiel #15
0
        /// <summary>
        /// Jauna ieraksta pievienosana
        /// </summary>
        /// <param name="cinema">Dati</param>
        /// <returns>Izveidotais ieraksts</returns>
        public static Cinemas Create(Cinemas cinema)
        {
            using (var db = new DB())
            {
                cinema = db.Cinemas.Add(cinema);

                db.SaveChanges();

                return(cinema);
            }
        }
        public async Task <ActionResult> Edit([Bind(Include = "id,Name,Description,Image,likes,dislikes,latitude,longitude")] Cinemas cinemas)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cinemas).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cinemas));
        }
        public async Task <ActionResult> Create([Bind(Include = "id,Name,Description,Image,likes,dislikes,latitude,longitude")] Cinemas cinemas)
        {
            if (ModelState.IsValid)
            {
                db.Cinemas.Add(cinemas);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(cinemas));
        }
Beispiel #18
0
        public async Task <IHttpActionResult> PostCinemas(Cinemas cinemas)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Cinemas.Add(cinemas);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = cinemas.id }, cinemas));
        }
Beispiel #19
0
        /// <summary>
        /// Kino atjaunosana
        /// </summary>
        /// <param name="cinema">Kino dati</param>
        /// <returns>Kino dati</returns>
        public static Cinemas Update(Cinemas cinema)
        {
            using (var db = new DB())
            {
                var existing = db.Cinemas.Find(cinema.Id);
                existing.Name   = cinema.Name;
                existing.Adress = cinema.Adress;

                db.SaveChanges();

                return(existing);
            }
        }
Beispiel #20
0
        private void CinemaClick(object sender, RoutedEventArgs e)
        {
            Cinemas cinema = (Cinemas)((Button)sender).DataContext;

            deleteCinemaButton.Visibility = Visibility.Visible;
            changeCinemaButton.Visibility = Visibility.Visible;
            cinemaName.Text   = cinema.name;
            cinemaAdress.Text = cinema.adress;
            cinemaStars.Text  = cinema.stars_quantity.ToString();
            nearestMetro.Text = cinema.nearest_metro;
            this.cinema       = cinema;
            this.button       = (Button)sender;
        }
Beispiel #21
0
 private void OnSessionTypePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     try
     {
         List <String> SelSesiones      = SessionTypes.Where(s => s.IsSelectedItem).Select(z => z.SessionType).ToList();
         List <int>    IdsCinesAbiertos = CinemasPorSessionTypes.Where(s => SelSesiones.Contains(s.SessionType)).Select(z => z.CinemaId).Distinct().ToList();
         Cinemas.ToList().ForEach(c => c.IsSelectedItem = (IdsCinesAbiertos.Contains(c.Id)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #22
0
        // GET: Admin/Cinemas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cinemas cinemas = db.Cinemas.Find(id);

            if (cinemas == null)
            {
                return(HttpNotFound());
            }
            return(View(cinemas));
        }
Beispiel #23
0
        public async Task <IHttpActionResult> DeleteCinemas(int id)
        {
            Cinemas cinemas = await db.Cinemas.FindAsync(id);

            if (cinemas == null)
            {
                return(NotFound());
            }

            db.Cinemas.Remove(cinemas);
            await db.SaveChangesAsync();

            return(Ok(cinemas));
        }
        // GET: Cinemas/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cinemas cinemas = await db.Cinemas.FindAsync(id);

            if (cinemas == null)
            {
                return(HttpNotFound());
            }
            return(View(cinemas));
        }
Beispiel #25
0
        private void CreateCinemaClick(object sender, RoutedEventArgs e)
        {
            bool    check  = true;
            Cinemas cinema = new Cinemas();

            cinema.name   = cinemaName.Text;
            cinema.adress = cinemaAdress.Text;
            try
            {
                cinema.stars_quantity = Convert.ToInt32(cinemaStars.Text);
            }
            catch
            {
                check = false;
            }
            cinema.nearest_metro = nearestMetro.Text;

            int i = -1; bool isFindId = true;

            while (isFindId)
            {
                i++;
                isFindId = false;
                foreach (Cinemas kino in main.bd.Cinemas)
                {
                    if (kino.id == i)
                    {
                        isFindId = true;
                    }
                }
            }
            cinema.id = i;

            if (check)
            {
                main.bd.Cinemas.Add(cinema);
                main.bd.SaveChanges();
                Button button = new Button();
                button.Content     = cinema.id + ": " + cinema.name;
                button.FontSize    = 15;
                button.Click      += CinemaClick;
                button.DataContext = cinema;
                cinemas.Children.Add(button);
            }
            else
            {
                MessageBox.Show("Проблемы со звездами");
            }
        }
Beispiel #26
0
        private void fillHalls()
        {
            halls.Children.Clear();
            Cinemas cinema = (Cinemas)((ComboBoxItem)cinemas.SelectedValue).DataContext;

            foreach (Halls hall in cinema.Halls)
            {
                Button button = new Button();
                button.Content     = hall.id + ": " + hall.name;
                button.FontSize    = 15;
                button.Click      += HallClick;
                button.DataContext = hall;
                halls.Children.Add(button);
            }
        }
Beispiel #27
0
 private bool CanExecuteFindPeliCommand()
 {
     try
     {
         bool ret = false;
         ret = (ret || (Peliculas != null && Peliculas.Any(p => p.IsSelectedItem)));
         ret = (ret || (Cinemas != null && Cinemas.Any(p => p.IsSelectedItem)));
         ret = (ret || (SessionTypes != null && SessionTypes.Any(p => p.IsSelectedItem)));
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #28
0
        private void changeHalls()
        {
            Cinemas cinema = ((Cinemas)((ComboBoxItem)cinemas.SelectedItem).DataContext);

            halls.Items.Clear();
            foreach (Halls hall in cinema.Halls)
            {
                ComboBoxItem comboBox = new ComboBoxItem();
                comboBox.Content     = hall.id.ToString() + ": " + hall.name;
                comboBox.FontSize    = 15;
                comboBox.DataContext = hall;
                halls.Items.Add(comboBox);
            }
            halls.SelectedIndex = 0;
        }
        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);
                }
            }
        }
Beispiel #30
0
        public void DeleteCinema(CinemaVM cinemaVM)
        {
            CinemaMovieShowBooking deleteCinema = new CinemaMovieShowBooking {
                CinemaName = cinemaVM.Cinema, CinemaTown = cinemaVM.Town
            };

            try
            {
                repo.Delete(deleteCinema);
                Cinemas.Remove(cinemaVM);
                RefreshVMs();
            }
            catch (Exception)
            {
                throw;
            }
        }