Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }
Пример #4
0
        /// <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;
        }
Пример #5
0
        /// <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;
        }
Пример #6
0
 public bool IsPerformanceValid(Performance p)
 {
     return viewBL.IsPerformanceValid(p);
 }
Пример #7
0
 public bool UpdatePerformance(Performance p)
 {
     return viewBL.UpdatePerformance(p);
 }
Пример #8
0
        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);
            }
        }
Пример #9
0
 public void RemovePerformance(Performance performance)
 {
     if (!performanceDao.Delete(performance.Id))
         throw new PerformanceException("Cannot remove performance!");
 }
Пример #10
0
        public void CreatePerformance(Performance performance)
        {
            if (performance == null)
                throw new ArgumentNullException("Invalid performance!");

            if (!performanceDao.Insert(performance))
                throw new PerformanceException("Cannot create performance!");
        }