private void ReserveTicket()
        {
            if (validation.ValidateFields(new Control[] { ticketFirstNameInput, ticketLastNameInput, ticketConcertInput, ticketEmailInput }) && validation.ValidateMail(ticketEmailInput.Text))
            {
                var newTicket = new TicketOrders
                {
                    FirstName   = ticketFirstNameInput.Text,
                    LastName    = ticketLastNameInput.Text,
                    ConcertID   = Int32.Parse(ticketConcertInput.SelectedValue.ToString().Split(new string[] { " | " }, StringSplitOptions.None)[0]),
                    Mail        = ticketEmailInput.Text,
                    PhoneNumber = ticketPhoneNumberInput.Text,
                    VIPTicket   = ticketVipCheckbox.IsChecked ?? false
                };

                context.TicketOrders.Add(newTicket);
                context.SaveChanges();
                this.NavigationService.Navigate(new Uri("Windows/TicketOrdersList.xaml", UriKind.Relative));
            }
            else
            {
                wrongMailText.Text            = "This field cannot be empty";
                wrongMailText.Visibility      = Visibility.Visible;
                emptyConcertText.Visibility   = Visibility.Visible;
                emptyFirstNameText.Visibility = Visibility.Visible;
                emptyLastNameText.Visibility  = Visibility.Visible;
            }
            if (!validation.ValidateMail(ticketEmailInput.ToString()) && !String.IsNullOrWhiteSpace(ticketEmailInput.Text))
            {
                wrongMailText.Text       = "Invalid e-mail address!";
                wrongMailText.Visibility = Visibility.Visible;
            }
        }
        private void CreateConcert()
        {
            if (validation.ValidateFields(new Control[] { concertPlaceNameComboBox, concertArtistNameComboBox, concertDateInput, concertBaseTicketPriceInput, concertVipTicketPriceInput, concertRemainingCapacityInput })
                &&
                validation.ValidateCapacity(concertRemainingCapacityInput.Text, context.Places
                                            .Where(u => u.PlaceName.ToString().Equals(concertPlaceNameComboBox.SelectedValue.ToString()))
                                            .Select(u => u.Capacity)
                                            .FirstOrDefault()))
            {
                placeCapacity = context.Places
                                .Where(u => u.PlaceName.ToString().Equals(concertPlaceNameComboBox.SelectedValue.ToString()))
                                .Select(u => u.Capacity)
                                .FirstOrDefault();
                var newConcert = new Concerts()
                {
                    PlaceID = context.Places
                              .Where(u => u.PlaceName.ToString().Equals(concertPlaceNameComboBox.SelectedValue.ToString()))
                              .Select(u => u.PlaceID)
                              .FirstOrDefault(),
                    ArtistID = context.Artists
                               .Where(u => u.ArtistName.ToString().Equals(concertArtistNameComboBox.SelectedValue.ToString()))
                               .Select(u => u.ArtistID)
                               .FirstOrDefault(),
                    EventDate         = concertDateInput.SelectedDate.Value,
                    BaseTicketPrice   = Convert.ToDecimal(concertBaseTicketPriceInput.Text),
                    VIPTicketPrice    = Convert.ToDecimal(concertVipTicketPriceInput.Text),
                    RemainingCapacity = Convert.ToInt32(concertRemainingCapacityInput.Text)
                };

                context.Concerts.Add(newConcert);
                context.SaveChanges();
                this.NavigationService.Navigate(new Uri("Windows/ConcertsList.xaml", UriKind.Relative));
            }
            else
            {
                emptyArtistText.Visibility     = Visibility.Visible;
                emptyPlaceText.Visibility      = Visibility.Visible;
                emptyDateText.Visibility       = Visibility.Visible;
                emptyBaseTicketText.Visibility = Visibility.Visible;
                emptyVipTextText.Visibility    = Visibility.Visible;
                emptyCapacityText.Text         = "This field cannot be empty";
                emptyCapacityText.Visibility   = Visibility.Visible;
            }
            if (!String.IsNullOrWhiteSpace(concertRemainingCapacityInput.Text))
            {
                if (!validation.ValidateCapacity(concertRemainingCapacityInput.Text, placeCapacity))
                {
                    emptyCapacityText.Text       = "Cannot enter value higher than max capacity!";
                    emptyCapacityText.Visibility = Visibility.Visible;
                }
            }
        }
        private void AddPlace()
        {
            if (validation.ValidateFields(new Control[] { placeNameInput, placeCapacityInput, placeOpeningHourInput, placeClosingHourInput, placeRentalPriceInput }) &&
                validation.ValidateHour(placeOpeningHourInput) &&
                validation.ValidateHour(placeClosingHourInput))
            {
                var newPlace = new Places()
                {
                    PlaceName   = placeNameInput.Text,
                    Capacity    = Int32.Parse(placeCapacityInput.Text),
                    BarArea     = placeBarAreaCheckBox.IsChecked ?? false,
                    VIPArea     = placeVipAreaCheckBox.IsChecked ?? false,
                    OpeningHour = Int32.Parse(placeOpeningHourInput.Text),
                    ClosingHour = Int32.Parse(placeClosingHourInput.Text),
                    AdultsOnly  = placeAdultsOnlyCheckBox.IsChecked ?? false,
                    RentalPrice = Int32.Parse(placeRentalPriceInput.Text)
                };

                context.Places.Add(newPlace);
                context.SaveChanges();
                this.NavigationService.Navigate(new Uri("Windows/PlacesList.xaml", UriKind.Relative));
            }
            else
            {
                emptyOpeningText.Text        = "This field cannot be empty";
                emptyClosingText.Text        = "This field cannot be empty";
                emptyCapacityText.Visibility = Visibility.Visible;
                emptyClosingText.Visibility  = Visibility.Visible;
                emptyOpeningText.Visibility  = Visibility.Visible;
                emptyRentalText.Visibility   = Visibility.Visible;
                emptyPlaceText.Visibility    = Visibility.Visible;
            }
            if (!validation.ValidateHour(placeOpeningHourInput) && !String.IsNullOrWhiteSpace(placeOpeningHourInput.Text))
            {
                emptyOpeningText.Text       = "Invalid hour!";
                emptyOpeningText.Visibility = Visibility.Visible;
            }
            if (!validation.ValidateHour(placeClosingHourInput) && !String.IsNullOrWhiteSpace(placeClosingHourInput.Text))
            {
                emptyClosingText.Text       = "Invalid hour!";
                emptyClosingText.Visibility = Visibility.Visible;
            }
        }
Пример #4
0
        private void AddArtist()
        {
            if (validation.ValidateFields(new Control[] { artistNameInput, artistMusicGenreInput, artistPerformancePriceInput }))
            {
                var newArtist = new Artists()
                {
                    ArtistName         = artistNameInput.Text,
                    MusicGenre         = artistMusicGenreInput.SelectedValue.ToString(),
                    PerformancePrice   = Convert.ToInt32(artistPerformancePriceInput.Text),
                    ExplicitContent    = artistExplicitCheckbox.IsChecked ?? false,
                    ArtistAvailability = artistAvailabilityCheckbox.IsChecked ?? false
                };

                context.Artists.Add(newArtist);
                context.SaveChanges();
                this.NavigationService.Navigate(new Uri("Windows/ArtistsList.xaml", UriKind.Relative));
            }
            else
            {
                emptyArtistText.Visibility      = Visibility.Visible;
                emptyMusicText.Visibility       = Visibility.Visible;
                emptyPerformanceText.Visibility = Visibility.Visible;
            }
        }