Beispiel #1
0
        private void Validate_btn_Click(object sender, RoutedEventArgs e)
        {
            if (Quantity_ComboBox.SelectedItem != null)
            {
                var context = new CircusContext();

                var ticketOrder = new TicketOrder()
                {
                    Price        = Convert.ToDecimal(Price_TextBlock.Text),
                    TicketNumber = Convert.ToInt32(Quantity_ComboBox.SelectedItem),
                    OrderDate    = DateTime.Today,
                };

                ShowOrder showOrder = CircusInformation.AssociatedShowWithOrder(SelectedShow, ticketOrder);
                ticketOrder.ManyShowOrder.Add(showOrder);

                context.Update(ticketOrder);
                context.SaveChanges();

                MessageBox.Show("Ticket(s) ordered for the show : " + SelectedShow.Name);
                this.Close();
            }
            else
            {
                MessageBox.Show("Select a quantity");
            }
        }
        private void AddShow_Button_Click(object sender, RoutedEventArgs e)
        {
            if (IsAllBoxFilled() == true)
            {
                var context = new CircusContext();

                Show newShow = new Show();
                newShow.Name     = Name_TextBox.Text;
                newShow.Date     = Date_DatePicker.SelectedDate.Value;
                newShow.Location = Location_TextBox.Text;
                newShow.Price    = Convert.ToInt32(Price_TextBox.Text);

                List <Performer> selectedPerformers = new List <Performer>();

                foreach (var item in Performers_ListBox.SelectedItems)
                {
                    Performer performer = (Performer)item;
                    selectedPerformers.Add(performer);
                }

                List <PerformerShow> performerShows = CircusInformation.AssociatedShowWithPerformer(newShow, selectedPerformers);
                newShow.ManyPerformerShow.AddRange(performerShows);

                context.Update(newShow);
                context.SaveChanges();

                MessageBox.Show("New Show added");
            }
            else
            {
                MessageBox.Show("You must filled every fields");
            }
        }
Beispiel #3
0
        public dynamic PutNewUser(string name, string password)
        {
            using (var context = new CircusContext())
            {
                var user = new User();
                user.Name        = name;
                user.Password    = password;
                user.StaffMember = false;
                context.Users.AddRange(user);
                context.SaveChanges();

                string jsonString;
                jsonString = System.Text.Json.JsonSerializer.Serialize("User added.");
                return(jsonString);
            }
        }
        private void Send_Btn_Click(object sender, RoutedEventArgs e)
        {
            string mail    = Mail_TextBox.Text;
            string message = Message_TextBox.Text;

            if (mail != String.Empty && message != String.Empty)
            {
                var     context    = new CircusContext();
                Contact newContact = CreateContact(mail, message);
                context.Add(newContact);
                context.SaveChanges();
                MessageBox.Show("Message send");
                this.Close();
            }
            else
            {
                MessageBox.Show("You have to complete every field");
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start creation of the database");
            using (var context = new CircusContext())
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();



                var troupe1 = new Troupe()
                {
                    NameTroupe  = "The Croustillants",
                    MembersName = new List <MemberTroupe>()
                    {
                        new MemberTroupe {
                            Name = "Pablo", Age = 28, Job = "Acrobate"
                        },
                        new MemberTroupe {
                            Name = "Ortencia", Age = 62, Job = "Acrobate"
                        },
                        new MemberTroupe {
                            Name = "Picasso", Age = 58, Job = "Acrobate"
                        },
                        new MemberTroupe {
                            Name = "Lolita", Age = 24, Job = "Acrobate"
                        },
                    },
                };

                var troupe2 = new Troupe()
                {
                    NameTroupe  = "The Clowns",
                    MembersName = new List <MemberTroupe>()
                    {
                        new MemberTroupe {
                            Name = "Albert", Age = 28, Job = "Clown"
                        },
                        new MemberTroupe {
                            Name = "Filibert", Age = 62, Job = "Clown"
                        },
                        new MemberTroupe {
                            Name = "Gertrude", Age = 58, Job = "Clown"
                        },
                        new MemberTroupe {
                            Name = "Gaston", Age = 24, Job = "Clown"
                        },
                    },
                };

                var show1 = new Show()
                {
                    ShowName      = "Vol-au-Vent",
                    MemberTroupes = troupe1.MembersName,
                    TroupeName    = troupe1.NameTroupe,
                    ShowType      = "Acrobatics",
                    Description   = "Personnes qui volent"
                };
                List <Show> show1List = new List <Show>();
                show1List.Add(show1);

                troupe1.ShowsList = show1List;
                troupe1.ShowType  = show1.ShowType;

                var show2 = new Show()
                {
                    ShowName      = "Qu'est-ce-qu'on se marre",
                    MemberTroupes = troupe2.MembersName,
                    TroupeName    = troupe2.NameTroupe,
                    ShowType      = "Clown show",
                    Description   = "Clowns qui font rire"
                };

                List <Show> show2List = new List <Show>();
                show2List.Add(show2);

                troupe2.ShowsList = show2List;
                troupe2.ShowType  = show2.ShowType;

                var calendar1 = new Calendar()
                {
                    ShowDay = "Lundi, Jeudi, Samedi",
                    Name    = troupe1.NameTroupe,
                    Hour    = "14H-15h30"
                };

                var calendar2 = new Calendar()
                {
                    ShowDay = "Lundi, Jeudi, Samedi",
                    Name    = troupe2.NameTroupe,
                    Hour    = "16H-18h"
                };

                troupe1.CalendarShow = calendar1;
                troupe2.CalendarShow = calendar2;


                var user1 = new User()
                {
                    Name        = "Gruss",
                    Password    = "******",
                    StaffMember = false
                };

                var user2 = new User()
                {
                    Name        = "Arlette",
                    Password    = "******",
                    StaffMember = false
                };

                var staffUser = new User()
                {
                    Name        = "Staff",
                    Password    = "******",
                    StaffMember = true
                };

                var tickets1 = new TicketOffice()
                {
                    NameTroupe       = troupe1.NameTroupe,
                    ShowName         = show1.ShowName,
                    AvailableTickets = 200,
                    SoldTickets      = 10
                };

                var tickets2 = new TicketOffice()
                {
                    NameTroupe       = troupe2.NameTroupe,
                    ShowName         = show2.ShowName,
                    AvailableTickets = 150,
                    SoldTickets      = 20
                };

                context.Add(troupe1);
                context.Add(troupe2);
                context.Add(calendar1);
                context.Add(calendar2);
                context.Add(show1);
                context.Add(show2);
                context.Add(user1);
                context.Add(user2);
                context.Add(staffUser);
                context.Add(tickets1);
                context.Add(tickets2);
                context.SaveChanges();

                Console.WriteLine("End of the database creation");
                GetHost();
            }
        }
        static void Main(string[] args)
        {
            using (var context = new CircusContext())
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var performer1 = new Performer()
                {
                    Name         = "Moonlight",
                    CreationDate = DateTime.Today,
                    Descritpion  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. ",
                    Image        = "/References/MoonLight.jpg"
                };

                var performer2 = new Performer()
                {
                    Name         = "SnowFlake",
                    CreationDate = DateTime.Today,
                    Image        = "/References/snowflake.jpg",
                    Descritpion  = "SnowFlake reunites 8 lovers of circus and ice skating.They join the art of the circus and the disciplines on ice for the first time in our circus." +
                                   "The acrobats take this new iced field game by storm.Figure skating," +
                                   "freestyle skating and extreme skating are mixed with innovative acrobatics" +
                                   "and aerial exploits to create an unexpected show.Thrills guaranteed!",
                };

                var performer3 = new Performer()
                {
                    Name         = "WildFlower",
                    CreationDate = DateTime.Today,
                    Descritpion  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. ",
                    Image        = "/References/circus.jpg"
                };

                var performer4 = new Performer()
                {
                    Name         = "SleepWalking",
                    CreationDate = DateTime.Today,
                    Descritpion  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. ",
                    Image        = "/References/sleepwalking.jpg",
                };


                var show1 = new Show()
                {
                    Name        = "Crystal",
                    Location    = "Paris",
                    Descritpion = "Come and see this wonderfull figure skating show",
                    Date        = DateTime.Today.AddMonths(3),
                    Price       = 30,
                };

                var show2 = new Show()
                {
                    Name        = "Stars",
                    Location    = "Londres",
                    Descritpion = "Come and see this wonderfull dance show. Many dance groups will show you that the only limit is your imagination",
                    Date        = DateTime.Today.AddMonths(6),
                    Price       = 40
                };

                List <Show> shows = new List <Show>();
                shows.Add(show1);
                shows.Add(show2);

                List <Performer> performers = new List <Performer>();
                performers.Add(performer1);
                performers.Add(performer2);
                performers.Add(performer3);
                performers.Add(performer4);



                var newPersons = (from i in Enumerable.Range(0, 5)
                                  select new User {
                    Name = "Maximus" + i, Password = "******"
                }).ToList();

                List <TicketOrder> ticketOrders1 = GenerateTicketOrders(5, show1);
                List <TicketOrder> ticketOrders2 = GenerateTicketOrders(5, show2);
                List <TicketOrder> ticketOrders  = new List <TicketOrder>();
                ticketOrders.AddRange(ticketOrders1);
                ticketOrders.AddRange(ticketOrders2);

                List <ShowOrder> showOrders = AssociatedShowAndOrder(shows, ticketOrders);

                PerformerShow performerShow  = AssociatedPerformerWithShow(show2, performer1);
                PerformerShow performerShow2 = AssociatedPerformerWithShow(show2, performer3);
                PerformerShow performerShow3 = AssociatedPerformerWithShow(show1, performer2);

                List <Show> newShows = GenerateShows(15);

                context.AddRange(performers);
                context.AddRange(shows);
                context.AddRange(newShows);
                context.AddRange(newPersons);
                context.AddRange(ticketOrders);
                context.AddRange(showOrders);
                context.AddRange(performerShow);
                context.AddRange(performerShow2);
                context.AddRange(performerShow3);
                context.SaveChanges();
            }
        }