Example #1
0
        void AddActivities()
        {
            Console.WriteLine();
            Console.WriteLine("ADDING ACTIVITIES AND ASSIGNING ROOMS...");

            CityHall c = service.FindCityHallByName("Valencia");

            Gym g = c.FindGymByName("Gym1");

            try
            {
                // Activity(Days activityDays, String description, TimeSpan duration, DateTime finishDate, int maximumEnrollments, int minimumEnrollments, double price, DateTime startDate, DateTime startHour)
                Activity a = new Activity(Days.Mon | Days.Wed | Days.Fri, "Yoga 101", new TimeSpan(0, 45, 0), new DateTime(2021, 3, 12), 20, 6, 100, new DateTime(2021, 2, 8), Convert.ToDateTime("09:30:00"));
                g.AddActivity(a);
                service.AddActivity(a);

                Console.WriteLine("Activity days");
                Console.Out.WriteLine("  " + a.ActivityDays);
                if ((a.ActivityDays & Days.Fri) == Days.Fri)
                {
                    Console.WriteLine("   Activity is on Friday");
                }
                else
                {
                    Console.WriteLine("   Activity is NOT on Friday");
                }

                // Adding Rooms for an Activity
                a.AddRoom(g.FindRoom(3));
                a.AddRoom(g.FindRoom(4));
                a.AddRoom(g.FindRoom(5));
                service.Commit();

                // Testing rooms assigned
                Console.WriteLine("\nRooms assigned to " + a.Description);
                foreach (Room ro in a.Rooms)
                {
                    System.Console.WriteLine("   " + ro.Number + " assigned");
                }

                // Adding another Activity
                a = new Activity(Days.Mon | Days.Wed | Days.Fri, "Zumba 101", new TimeSpan(0, 45, 0), new DateTime(2021, 5, 31), 20, 6, 100, new DateTime(2021, 3, 3), Convert.ToDateTime("09:30:00"));
                g.AddActivity(a);
                service.AddActivity(a);


                // Adding Rooms for an Activity
                g = c.FindGymByName("Gym1");
                a.AddRoom(g.FindRoom(1));
                a.AddRoom(g.FindRoom(6));
                service.Commit();

                a.AddRoom(g.FindRoom(5));
                service.Commit();
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // Adding another Activity
                Activity a = new Activity(Days.Mon | Days.Wed | Days.Fri, "Disco 101", new TimeSpan(0, 45, 0), new DateTime(2021, 5, 31), 20, 6, 100, new DateTime(2021, 7, 3), Convert.ToDateTime("09:30:00"));
                g.AddActivity(a);
                service.AddActivity(a);
            }
            catch (Exception e)
            {
                printError(e);
            }

            try
            {
                // Adding another Activity
                Activity a = new Activity(Days.Mon | Days.Wed | Days.Fri, "Jazz 101", new TimeSpan(0, 45, 0), new DateTime(2021, 7, 30), 20, 6, 100, DateTime.Today, Convert.ToDateTime("09:30:00"));
                g.AddActivity(a);
                service.AddActivity(a);
            }
            catch (Exception e)
            {
                printError(e);
            }
        }
Example #2
0
 private void LoadData()
 {
     ciudad   = service.FindCityHallByName("Valencia");
     gimnasio = service.FindGymByName("Gym1");
 }