コード例 #1
0
ファイル: PerformanceViewModel.cs プロジェクト: amigobv/UFO
        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
ファイル: PerformanceViewModel.cs プロジェクト: amigobv/UFO
        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
ファイル: PerformanceViewModel.cs プロジェクト: amigobv/UFO
        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
ファイル: ViewerImpl.cs プロジェクト: amigobv/UFO
        /// <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
ファイル: ViewerImpl.cs プロジェクト: amigobv/UFO
        /// <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
ファイル: UfoService.asmx.cs プロジェクト: amigobv/UFO
 public bool IsPerformanceValid(Performance p)
 {
     return viewBL.IsPerformanceValid(p);
 }
コード例 #7
0
ファイル: UfoService.asmx.cs プロジェクト: amigobv/UFO
 public bool UpdatePerformance(Performance p)
 {
     return viewBL.UpdatePerformance(p);
 }
コード例 #8
0
ファイル: ManagerImpl.cs プロジェクト: amigobv/UFO
        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
ファイル: ManagerImpl.cs プロジェクト: amigobv/UFO
 public void RemovePerformance(Performance performance)
 {
     if (!performanceDao.Delete(performance.Id))
         throw new PerformanceException("Cannot remove performance!");
 }
コード例 #10
0
ファイル: ManagerImpl.cs プロジェクト: amigobv/UFO
        public void CreatePerformance(Performance performance)
        {
            if (performance == null)
                throw new ArgumentNullException("Invalid performance!");

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