public PerformanceViewModel(VenueViewModel venueVm, ArtistViewModel artistVm, DateTime day, IManager manager) { this.manager = manager; this.performance = new Performance(); this.performance.Start = day; var artist = manager.GetArtistByName(artistVm.Name); if (artist != null && artist.Count > 0) this.performance.Artist = artist.ElementAt(0); else this.performance.Artist = new Artist(); var venue = manager.GetVenueById(venueVm.Id); if (venue != null) this.performance.Venue = venue; this.venueVm = venueVm; this.artistVm = artistVm; this.day = day; this.artists = new List<ArtistViewModel>(); this.venues = new List<VenueViewModel>(); SaveCommand = new RelayCommand(o => manager.UpdatePerformance(performance)); RemoveCommand = new RelayCommand(o => manager.RemovePerformance(performance)); }
public PerformanceViewModel(IManager manager) { this.manager = manager; this.performance = new Performance(); this.venueVm = new VenueViewModel(manager); this.artistVm = new ArtistViewModel(manager); this.day = new DateTime(2000, 01, 01); this.artists = new List<ArtistViewModel>(); this.venues = new List<VenueViewModel>(); SaveCommand = new RelayCommand(o => manager.UpdatePerformance(performance)); RemoveCommand = new RelayCommand(o => manager.RemovePerformance(performance)); }
public PerformanceViewModel(Performance performance, IManager manager) { this.manager = manager; this.performance = performance; this.venueVm = new VenueViewModel(performance.Venue, manager); this.artistVm = new ArtistViewModel(performance.Artist, (manager)); this.day = new DateTime(performance.Start.Year, performance.Start.Month, performance.Start.Day, performance.Start.Hour, performance.Start.Minute, performance.Start.Second); this.artists = new List<ArtistViewModel>(); this.venues = new List<VenueViewModel>(); SaveCommand = new RelayCommand(o => manager.UpdatePerformance(performance)); RemoveCommand = new RelayCommand(o => manager.RemovePerformance(performance)); }
/// <summary> /// Updates the performance. /// </summary> /// <param name="performance">The performance.</param> /// <exception cref="System.ArgumentNullException">Invalid performance!</exception> /// <exception cref="VenueException">Cannot update performance!</exception> public bool UpdatePerformance(Performance performance) { if (performance == null) return false; if (performanceDao.FindById(performance.Id) != null) { if (!performanceDao.Update(performance)) return false; } return true; }
/// <summary> /// Determines whether [is performance valid] [the specified p]. /// </summary> /// <param name="p">The p.</param> /// <returns></returns> public bool IsPerformanceValid(Performance p) { if (p == null || p.Artist == null || p.Venue == null) return false; DateTime start = new DateTime(p.Start.Year, p.Start.Month, p.Start.Day, 0, 0, 0); DateTime end = new DateTime(p.Start.Year, p.Start.Month, p.Start.Day, 23, 59, 59); var listPerformances = performanceDao.FindBetween(start, end); foreach (var performance in listPerformances) { if (p.Artist.Equals(performance.Artist)) { DateTime next = p.Start.AddHours(1); DateTime prev = p.Start.AddHours(-1); if (p.Start.Equals(performance.Start) || next.Equals(performance.Start) || prev.Equals(performance.Start)) return false; } } return true; }
public bool IsPerformanceValid(Performance p) { return viewBL.IsPerformanceValid(p); }
public bool UpdatePerformance(Performance p) { return viewBL.UpdatePerformance(p); }
public void UpdatePerformance(Performance performance) { if (performance == null) throw new ArgumentNullException("Invalid performance!"); if (performanceDao.FindById(performance.Id) != null) { if (!performanceDao.Update(performance)) throw new VenueException("Cannot update performance!"); } else { CreatePerformance(performance); } }
public void RemovePerformance(Performance performance) { if (!performanceDao.Delete(performance.Id)) throw new PerformanceException("Cannot remove performance!"); }
public void CreatePerformance(Performance performance) { if (performance == null) throw new ArgumentNullException("Invalid performance!"); if (!performanceDao.Insert(performance)) throw new PerformanceException("Cannot create performance!"); }