Esempio n. 1
0
 public Performance Create(Performance performance)
 {
     var cmd = CreateInsertCommand(performance.ArtistId, performance.VenueId, performance.SpectacledayTimeSlot);
     db.ExecuteNonQuery(cmd);
     performance.Id = (int)((MySqlCommand)cmd).LastInsertedId;
     return performance;
 }
Esempio n. 2
0
 public void Delete(Performance performance)
 {
     var cmd = CreateDeleteCommand(performance.Id);
     if (db.ExecuteNonQuery(cmd) != 1) {
         throw new EntityNotFoundException($"Delete: Performance with id {performance.Id} not found.");
     }
 }
Esempio n. 3
0
        public void SetUp()
        {
            transaction = new TransactionScope();

            DALFactory factory = DALFactory.GetInstance();
            db = factory.CreateDatabase();
            dao = factory.CreatePerformanceDAO(db);

            performance1 = new Performance {
                Id = 1,
                ArtistId = 1,
                SpectacledayTimeSlot = 1,
                VenueId = 1
            };

            performance2 = new Performance {
                Id = 2,
                ArtistId = 2,
                VenueId = 2,
                SpectacledayTimeSlot = 2
            };

            IList<string> sqls = new List<string> {
                "SET FOREIGN_KEY_CHECKS=0",
                "DELETE FROM `performance`",
                "INSERT INTO `performance` (`id`, `artist_id`, `venue_id`, `spectacleday_timeslot_id`) "
                + "VALUES (1, 1, 1, 1)",
                "INSERT INTO `performance` (`id`, `artist_id`, `venue_id`, `spectacleday_timeslot_id`) "
                + "VALUES (2, 2, 2, 2)"
            };
            runDbCommands(db, sqls);
        }
Esempio n. 4
0
 public void TestCreate()
 {
     var newPerformance = new Performance {
         Id = -1,
         ArtistId = 3,
         VenueId = 3,
         SpectacledayTimeSlot = 3
     };
     newPerformance = dao.Create(newPerformance);
     Assert.True(newPerformance.Id != -1);
     Assert.True(dao.GetById(newPerformance.Id).IsEqualTo(newPerformance));
 }
Esempio n. 5
0
 public Spectacleday GetForPerformance(Performance performance)
 {
     Spectacleday spectacleday = null;
     DbCommand cmd = createSelectForPerformanceCommand(performance.Id);
     using (IDataReader reader = db.ExecuteReader(cmd)) {
         if (reader.Read()) {
             spectacleday = createSpectacledayFromReader(reader);
         }
     }
     if (spectacleday == null) {
         throw new EntityNotFoundException();
     }
     return spectacleday;
 }
Esempio n. 6
0
 public TimeSlot GetForPerformance(Performance performance)
 {
     TimeSlot timeSlot = null;
     DbCommand cmd = createSelectForPerformance(performance.SpectacledayTimeSlot);
     using (IDataReader reader = db.ExecuteReader(cmd)) {
         if (reader.Read()) {
             timeSlot = createTimeSlotFromReader(reader);
         }
     }
     if (timeSlot == null) {
         throw new EntityNotFoundException();
     }
     return timeSlot;
 }
		public async void LoadPerformances() {
			var areas = await blAsync.GetAreasAsync();
			var performances = await blAsync.GetPerformanesForSpetacleDayAsync(spectacleDay);
			var timeSlots = await blAsync.GetSpectacleDayTimeSlotsForSpectacleDayAsync(spectacleDay);

			ObservableCollection<TimeSlotViewModel> timeSlotViewModels = new ObservableCollection<TimeSlotViewModel>();
			foreach (var ts in timeSlots) {
				timeSlotViewModels.Add(new TimeSlotViewModel(ts));
			}

			Areas.Clear();
			foreach (var area in areas) {
				ObservableCollection<ScheduleVenueViewModel> venueViewModels = new ObservableCollection<ScheduleVenueViewModel>();
				var venues = await blAsync.GetVenuesForAreaAsync(area);
				foreach (var v in venues) {
					ObservableCollection<PerformanceViewModel> performanceViewModels = new ObservableCollection<PerformanceViewModel>();
					foreach (var ts in timeSlots) {
						var performance = performances
							.Where(p => p.VenueId == v.Id)
							.Where(p => p.SpectacledayTimeSlot == ts.Id)
							.FirstOrDefault();
						if (performance == null) {
							// Insert new performance as placeholder
							performance = new Performance {
								VenueId = v.Id,
								SpectacledayTimeSlot = ts.Id
							};
						}
						var vm = new PerformanceViewModel(performance);
						vm.PropertyChanged += PerformancePropertyChanged;
						performanceViewModels.Add(vm);
					}

					ScheduleVenueViewModel venueViewModel = new ScheduleVenueViewModel(v, performanceViewModels);
					venueViewModels.Add(venueViewModel);
				}
				var areaViewModel = new ScheduleAreaViewModel(area, timeSlotViewModels, venueViewModels, blAsync);
				Areas.Add(areaViewModel);
			}
		}
Esempio n. 8
0
        private static void TestPerformance(IDatabase db, DALFactory dalFactory)
        {
            Console.WriteLine("*************************************");
            Console.WriteLine("PERFORMANCE TEST");

            IPerformanceDAO performanceDAO = dalFactory.CreatePerformanceDAO(db);

            Console.WriteLine("\nAll performances:");
            foreach (var performance in performanceDAO.GetAll()) {
                Console.WriteLine(performance);
            }

            Console.WriteLine("\nPerformance with ID=1:");
            Console.WriteLine(performanceDAO.GetById(1));

            Performance performance1 = new Performance() {
                SpectacledayTimeSlot = 1,
                ArtistId = 1
            };
            Performance newPerformance = performanceDAO.Create(performance1);
            Console.WriteLine("New Artist: " + newPerformance);
            Console.WriteLine("Inserted Artist: " + newPerformance);

            newPerformance.ArtistId = 3;
            performanceDAO.Update(newPerformance);
            Console.WriteLine("Updated performance: " + newPerformance);

            performanceDAO.Delete(performance1);
            Console.WriteLine("\nPerformance deleted");
        }
Esempio n. 9
0
 public void TestGetTimeSlotsForPerformances()
 {
     Performance p1 = new Performance() {
         VenueId = 1
     };
     Performance p2 = new Performance() {
         VenueId = 2
     };
     var performances = new List<Performance>();
     performances.Add(p1);
     performances.Add(p2);
     var venues = dao.GetForPerformances(performances);
     Assert.True(venues.Count() == 2);
     Venue ts = venues.First();
     Assert.True(venues.First().IsEqualTo(venue1));
 }
Esempio n. 10
0
 public PerformanceViewModel(Performance performance)
 {
     this.performance = performance;
     dirty = false;
 }
Esempio n. 11
0
 public TimeSlot GetTimeSlotForPerformance(Performance performance)
 {
     return bl.GetTimeSlotForPerformance(performance);
 }
Esempio n. 12
0
 public static bool IsEqualTo(this Performance p1, Performance p2)
 {
     return p1.Id == p2.Id
         && p1.VenueId == p2.VenueId
         && p1.ArtistId == p2.ArtistId
         && p1.SpectacledayTimeSlot == p2.SpectacledayTimeSlot;
 }
Esempio n. 13
0
 public Task<TimeSlot> GetTimeSlotForPerformanceAsync(Performance performance)
 {
     return Task.Run(() => GetTimeSlotForPerformance(performance));
 }
Esempio n. 14
0
 public Performance Update(Performance performance)
 {
     var cmd = CreateUpdateCommand(performance.Id, performance.ArtistId, performance.VenueId, performance.SpectacledayTimeSlot);
     if (db.ExecuteNonQuery(cmd) != 1) {
         throw new EntityNotFoundException();
     }
     return performance;
 }
Esempio n. 15
0
 public void TestGetTimeSlotsForPerformances()
 {
     Performance p1 = new Performance() {
         SpectacledayTimeSlot = 1
     };
     Performance p2 = new Performance() {
         SpectacledayTimeSlot = 2
     };
     var performances = new List<Performance>();
     performances.Add(p1);
     performances.Add(p2);
     var timeSlots = dao.GetForPerformances(performances);
     Assert.True(timeSlots.Count() == 2);
     TimeSlot ts = timeSlots.First();
     Assert.True(timeSlots.First().IsEqualTo(timeslot1));
 }
Esempio n. 16
0
 public void TestGetForPerformance()
 {
     Performance p = new Performance() {
         SpectacledayTimeSlot = 1
     };
     Assert.IsTrue(dao.GetForPerformance(p) != null);
 }
Esempio n. 17
0
 public override TimeSlot GetTimeSlotForPerformance(Performance performance)
 {
     return dalFactory.CreateTimeSlotDAO(db).GetForPerformance(performance);
 }
Esempio n. 18
0
 public abstract TimeSlot GetTimeSlotForPerformance(Performance performance);
Esempio n. 19
0
 public void TestUpdate()
 {
     var v1Tmp = new Performance {
         Id = performance1.Id,
         ArtistId = performance1.ArtistId,
         VenueId = 1,
         SpectacledayTimeSlot = performance1.SpectacledayTimeSlot
     };
     Assert.True(performance1.IsEqualTo(v1Tmp));
     performance1.ArtistId = 3;
     performance1.SpectacledayTimeSlot = 3;
     performance1.VenueId = 3;
     Assert.False(performance1.IsEqualTo(v1Tmp));
     Assert.True(dao.Update(performance1).IsEqualTo(performance1));
     Assert.True(dao.GetById(performance1.Id).IsEqualTo(performance1));
 }
Esempio n. 20
0
 public void SetUp()
 {
     performance = new Performance();
 }
Esempio n. 21
0
 public void TestGetTimeSlotsForPerformances()
 {
     Performance p1 = new Performance() {
         ArtistId = 1
     };
     Performance p2 = new Performance() {
         ArtistId = 2
     };
     var performances = new List<Performance>();
     performances.Add(p1);
     performances.Add(p2);
     var artists = dao.GetForPerformances(performances);
     Assert.True(artists.Count() == 2);
     Artist ts = artists.First();
     Assert.True(artists.First().IsEqualTo(artist1));
 }