Beispiel #1
0
        private async void AddEditAppointmentForm_Load(object sender, EventArgs e)
        {
            _halls = await _apiService.CustomGet <List <Model.Hall> >("GetHalls", _schedule.Cinema.CinemaId);

            var moviesApi = new APIService("movies");
            var movie     = await moviesApi.GetById <Model.Movie>(_movieId);

            HallsBox.DisplayMember = "Text";
            HallsBox.ValueMember   = "Value";
            foreach (var hall in _halls)
            {
                HallsBox.Items.Add(new { Text = hall.HallName + " " + hall.HallNumber, Value = hall.HallId });
            }
            Cinema.Text = _schedule.Cinema.Name;
            Day.Text    = $"{_day}, {_date.ToString("dd. MMM yyyy")}";
            Movie.Text  = movie.Title;
            if (_appointmentId.HasValue)
            {
                Title.Text = $"Appointment of:";
                var appApi = new APIService("Appointments");
                var app    = await appApi.GetById <Model.Appointments>(_appointmentId);

                Price.Text     = app.Price.ToString();
                StartsAt.Value = DateTime.Parse(app.StartsAt.ToString());
                var hallApi = new APIService("halls");
                var hall    = await hallApi.GetById <Model.Hall>(app.HallId);

                HallsBox.SelectedIndex = HallsBox.Items.IndexOf(new { Text = hall.HallName + " " + hall.HallNumber, Value = hall.HallId });
            }
            else
            {
                Title.Text = $"Appointment to:";
            }
        }
Beispiel #2
0
        private async void saveBtn_Click(object sender, EventArgs e)
        {
            var movieId = (select.SelectedItem as dynamic).Value;
            var Object  = new Model.CinemaDayMovie()
            {
                AiringDaysOfCinemaId = _airingDayId,
                MovieId = movieId
            };
            APIService cdmService = new APIService("cinemaDayMovie");
            await cdmService.Insert <Model.CinemaDayMovie>(Object);

            this.Close();
            _scheduleForm.Close();
            ScheduleForm sch = new ScheduleForm(_schedule.Cinema.CinemaId, _menuForm)
            {
                MdiParent = _menuForm,
                Dock      = DockStyle.Fill
            };

            var schedule = await _apiService.CustomGet <Model.Requests.CinemasScheduleRequest>("GetCinemasSchedule", _schedule.Cinema.CinemaId);

            CinemaDayMovieForm form = new CinemaDayMovieForm(sch, schedule, _menuForm, _airingDayId, _date, _day);

            sch.Show();
            _helper.ShowForm(form, 15);
            var messageBox = new CustomMessageBox();

            messageBox.Show("Movie added successfully", "success");
        }
Beispiel #3
0
        private async void ScheduleForm_Load(object sender, EventArgs e)
        {
            var schedule = await _apiService.CustomGet <Model.Requests.CinemasScheduleRequest>("GetCinemasSchedule", _cinemaId);

            _schedule  = schedule;
            Title.Text = $"{schedule.Cinema.Name} schedule";

            var list = new List <Model.dgvLists.ScheduleItem>();

            foreach (var item in schedule.AiringDaysOfCinema)
            {
                string airingDay      = "";
                int    numberOfMovies = 0;
                foreach (var day in schedule.AiringDays)
                {
                    if (item.AiringDayId == day.AiringDayId)
                    {
                        airingDay = day.Name;
                        break;
                    }
                }
                foreach (var movie in schedule.CinemaDayMovies)
                {
                    if (movie.AiringDaysOfCinemaId == item.AiringDaysOfCinemaId)
                    {
                        numberOfMovies++;
                    }
                }
                var Object = new Model.dgvLists.ScheduleItem()
                {
                    AiringDaysOfCinemasId = item.AiringDaysOfCinemaId,
                    Date           = item.Date.Date,
                    Day            = airingDay,
                    NumberOfMovies = numberOfMovies
                };
                list.Add(Object);
            }
            dgvSchedule.AutoGenerateColumns = false;

            dgvSchedule.DataSource = list;
            _list = list;
            selectList.DataSource = new string[] {
                "All",
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
                "Saturday",
                "Sunday"
            };
        }
Beispiel #4
0
        private async void dgvScheduledMovies_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                var cinemaDayMovieId = dgvScheduledMovies.Rows[e.RowIndex].Cells["CinemaDayMovieId"].Value;
                var movieId          = dgvScheduledMovies.Rows[e.RowIndex].Cells["MovieId"].Value;
                var action           = dgvScheduledMovies.Columns[e.ColumnIndex].Name;
                var cdmApi           = new APIService("cinemaDayMovie");
                var movieApi         = new APIService("movies");
                var cdm = await cdmApi.GetById <Model.CinemaDayMovie>(cinemaDayMovieId);

                var movie = await movieApi.GetById <Model.Movie>(cdm.MovieId);

                CustomMessageBox messageBox = new CustomMessageBox();

                if (action == "Delete")
                {
                    DialogResult dialogResult = MessageBox.Show($"Are you sure you want to permanently delete '{movie.Title}' on the {DateTime.Parse(_date.ToString()).ToShortDateString()}, {_day}?", "Delete movie?", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        await cdmApi.Delete <Model.CinemaDayMovie>(cinemaDayMovieId);

                        this.Close();
                        _scheduleForm.Close();
                        ScheduleForm sch = new ScheduleForm(_schedule.Cinema.CinemaId, _menuForm)
                        {
                            MdiParent = _menuForm,
                            Dock      = DockStyle.Fill
                        };

                        var schedule = await _apiService.CustomGet <Model.Requests.CinemasScheduleRequest>("GetCinemasSchedule", _schedule.Cinema.CinemaId);

                        CinemaDayMovieForm form = new CinemaDayMovieForm(sch, schedule, _menuForm, _airingDayId, _date, _day);
                        sch.Show();
                        _helper.ShowForm(form, 15);

                        messageBox.Show("Movie deleted successfully", "success");
                    }
                }
                else if (action == "Apps")
                {
                    AppointmentsForm form = new AppointmentsForm(_scheduleForm, _schedule, _menuForm, _airingDayId, _date, _day, int.Parse(cinemaDayMovieId.ToString()), int.Parse(movieId.ToString()), this);
                    _helper.CloseForm(this, 15);
                    _helper.ShowForm(form, 15);
                }
            }
        }
Beispiel #5
0
        public async void Init(int cinemaId, int cdmId, string day, string date, string cinemaName)
        {
            CinemaId   = cinemaId;
            CdmId      = cdmId;
            Day        = day;
            Date       = date;
            CinemaName = cinemaName;
            Title      = CinemaName + ", " + date + ", " + day;
            var cdm = await _cdmApi.GetById <Model.CinemaDayMovie>(CdmId);

            var movie = await _moviesApi.GetById <Model.Movie>(cdm.MovieId);

            Movie = movie;

            var apps = await _appApi.Get <List <Model.Appointments> >(null);

            apps.RemoveAll(app => app.CinemaDayMovieId != CdmId);

            foreach (var app in apps)
            {
                var hall = await _hallsApi.GetById <Model.Hall>(app.HallId);

                Model.ObservableLists.AppointmentItem newItem = new Model.ObservableLists.AppointmentItem()
                {
                    HallId            = hall.HallId,
                    AppId             = app.AppointmentId,
                    HallName          = hall.HallName,
                    HallNumber        = hall.HallNumber,
                    Price             = app.Price,
                    SoldSeats         = app.SoldSeats,
                    StartsAt          = app.StartsAt,
                    Display           = app.StartsAt + "h / Price: " + app.Price + " / ",
                    HallNumberOfSeats = hall.NumberOfseats
                };

                if (hall.NumberOfseats == app.SoldSeats)
                {
                    newItem.Full = true;
                }
                else
                {
                    newItem.Full = false;
                }

                if (newItem.Full)
                {
                    newItem.Display += "No more seats left";
                }
                else
                {
                    newItem.Display += "Sets: ";
                    newItem.Display += (hall.NumberOfseats - app.SoldSeats).ToString();
                }

                Apps.Add(newItem);
            }

            var products = await _cinemasApi.CustomGet <List <Model.Product> >("getProducts", CinemaId);

            foreach (var product in products)
            {
                Model.ObservableLists.ProductItem newItem = new Model.ObservableLists.ProductItem()
                {
                    Product = product,
                    Display = product.Name + " / Price: " + product.Price
                };
                Products.Add(newItem);
            }
        }