public AdministrationVM(IAdministrationServices service, IIOService ioService)
 {
     this.administrationService = service;
     this.ioService = ioService;
     this.currentArtistAdministration = new ArtistAdministrationVM(this.administrationService, ioService);
     this.currentCatagoryAdministration = new CatagoryAdministrationVM(this.administrationService);
     this.currentVenueAdministration = new VenueAdministrationVM(this.administrationService);
     this.currentPerformanceAdministration = new PerformanceAdministrationVM(this.administrationService);
     Login = new RelayCommand((c) =>
     {
         var box = c as PasswordBox;
         var password = box.Password;
         user = service.CheckUser(UserName, password);
         if(user != null)
         {
             LoggedIn = true;
             LoginFailedMessage = "";
             RaisePropertyChangedEvent(nameof(LoggedIn));
         }
         else
         {
             LoginFailedMessage = "UserId or Password is invalid";
             RaisePropertyChangedEvent(nameof(LoginFailedMessage));
         }
     });
 }
        public ArtistAdministrationVM(IAdministrationServices services, IIOService ioService)
        {
            this.administrationService = services;
            this.ioService = ioService;
            Artists = new ObservableCollection<ArtistVM>();

            AddNewArtistCommand = new RelayCommand(s => {
                CurrentArtist = new ArtistVM(new Artist(),administrationService, ioService);
                Artists.Add(CurrentArtist);
                RaisePropertyChangedEvent(nameof(CurrentArtist));
                RaisePropertyChangedEvent(nameof(Artists));
            });

            AppMessages.ArtistChanged.Register(this, (type) =>
            {
                if(type == AppMessages.ChangeType.Remove)
                {
                    LoadArtists();
                }
                RaisePropertyChangedEvent(nameof(CurrentArtist));
                RaisePropertyChangedEvent(nameof(Artists));
            });

            AppMessages.CatagoryChanged.Register(this, (type) =>
            {
                this.LoadItems();
                RaisePropertyChangedEvent(nameof(Artists));
                RaisePropertyChangedEvent(nameof(Catagory));
            });

            LoadArtists();
        }
        public PerformanceAdministrationVM(IAdministrationServices service)
        {
            this.administrationService = service;
            this.Performances = new ObservableCollection<PerformanceVM>();
            this.CurrentDate = DateTime.Now;
            this.LoadItems();

            AppMessages.ArtistChanged.Register(this,(changeType) => { this.LoadItems(); });
            AppMessages.CatagoryChanged.Register(this, (changeType) => { this.LoadItems(); });
            AppMessages.VenueChanged.Register(this, (changeType) => { this.LoadItems(); });

            ValidatePerformances = new RelayCommand((c) =>
            {
                if (this.ValidateProgram())
                {
                    AppMessages.ShowSuccessMessage.Send("Program is Valid");
                }
                else
                {
                    AppMessages.ShowErrorMessage.Send("Program is not Valid");
                }
            });
            SavePerformances = new RelayCommand((c) =>
            {
                if (!this.ValidateProgram())
                {
                    AppMessages.ShowErrorMessage.Send("Cannot Save Invalid Program");
                    return;
                }
                administrationService.DeletePerformancesByDay(CurrentDate);
                foreach(PerformanceVM vm in Performances)
                {
                    SavePerformanceHelper(vm.Col1);
                    SavePerformanceHelper(vm.Col2);
                    SavePerformanceHelper(vm.Col3);
                    SavePerformanceHelper(vm.Col4);
                    SavePerformanceHelper(vm.Col5);

                }
                AppMessages.ShowSuccessMessage.Send("Program Saved");
            });

            SendMailToArtists = new RelayCommand(c =>
            {
                if (!this.ValidateProgram())
                {
                    AppMessages.ShowErrorMessage.Send("Cannot Send Mails for Invalid Program");
                }
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += new DoWorkEventHandler((sender, args) => {
                    this.SendMails();
                });
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((sender, args) => {
                    AppMessages.ShowSuccessMessage.Send("Mails sent");
                });
                worker.RunWorkerAsync(System.Reflection.Assembly.GetExecutingAssembly().Location);

            });
        }
Пример #4
0
        public ArtistVM(Artist artist, IAdministrationServices service, IIOService ioservice)
        {
            this.administrationService = service;
            this.ioService = ioservice;
            this.artist = artist;
            this.Catagories = new ObservableCollection<Catagory>();
            this.Countries = new ObservableCollection<string>();
            LoadData();

            SaveCommand = new RelayCommand(async s => {
                if (!(await Validator.ValidateAllAsync()).IsValid)
                {
                    return;
                }
                artist = administrationService.SaveArtist(artist);
                if (artist != null && artist.Id > 0)
                {
                    AppMessages.ShowSuccessMessage.Send($"Artist {artist.Name} saved ");
                    AppMessages.ArtistChanged.Send(AppMessages.ChangeType.Change);
                    return;
                }
                AppMessages.ShowErrorMessage.Send($"Error occured while saving Artist {artist.Name} ");
            });

            DeleteCommand = new RelayCommand(c =>
            {
                if(artist.Id == null)
                {
                    AppMessages.ArtistChanged.Send(AppMessages.ChangeType.Remove);
                    return;
                }
                if (administrationService.DeleteArtist(artist))
                {
                    AppMessages.ShowSuccessMessage.Send($"Artist {artist.Name} removed ");
                    AppMessages.ArtistChanged.Send(AppMessages.ChangeType.Remove);
                    return;
                }
                AppMessages.ShowErrorMessage.Send($"Error occured while removing Artist {artist.Name} ");

            });
            ChangePictureCommand = new RelayCommand(c =>
            {
                this.artist.Picture = ioService.openFileBase64Encoded();
                RaisePropertyChangedEvent(nameof(Picture));
            });

            AddValidationRules();
        }
Пример #5
0
        public VenueVM(Venue venue, IAdministrationServices service)
        {
            this.venue = venue;
            this.administrationService = service;

            Save = new RelayCommand(c =>
            {
                if (!Validator.ValidateAll().IsValid)
                {
                    return;
                }
                this.venue = administrationService.SaveVenue(this.venue);
                if (this.venue != null && this.venue.Id > 0)
                {
                    AppMessages.ShowSuccessMessage.Send($"Venue {this.venue.Description} saved ");
                    AppMessages.VenueChanged.Send(AppMessages.ChangeType.Change);
                }
                else
                {
                    AppMessages.ShowErrorMessage.Send($"Error occured while saving Venue {this.venue.Description} ");
                }
            });

            Remove = new RelayCommand(c =>
            {
                try {
                    if (administrationService.DeleteVenue(this.venue))
                    {
                        AppMessages.ShowSuccessMessage.Send($"Venue {this.venue.Description} removed ");
                        AppMessages.VenueChanged.Send(AppMessages.ChangeType.Remove);
                        return;
                    }
                    else
                    {
                        AppMessages.ShowErrorMessage.Send($"Error occured while removing Venue {this.venue.Description} ");
                    }
                }catch(ElementInUseException e)
                {
                    AppMessages.ShowErrorMessage.Send(e.Message);
                }
            });
            ApplyValidationRules();
        }
Пример #6
0
        public CatagoryVM(Catagory cat, IAdministrationServices service)
        {
            catagory = cat;
            this.service = service;
            SaveCommand = new RelayCommand((c) =>
            {
                if (!Validator.ValidateAll().IsValid)
                {
                    return;
                }
                catagory = service.SaveCatagory(catagory);
                if (catagory != null && catagory.Id > 0)
                {
                    AppMessages.CatagoryChanged.Send(AppMessages.ChangeType.Change);
                    AppMessages.ShowSuccessMessage.Send($"Catagory {catagory.Name} saved");
                    return;
                }
                AppMessages.ShowErrorMessage.Send($"Error while saving Catagory {catagory.Name}");
            });
            DeleteCommand = new RelayCommand((c) =>
            {

                    try {
                        if (service.DelteCatagory(catagory))
                        {
                            AppMessages.CatagoryChanged.Send(AppMessages.ChangeType.Remove);
                            AppMessages.ShowSuccessMessage.Send($"Catagory {catagory.Name} removed");
                            return;
                        }

                    }catch(ElementInUseException e)
                    {
                        AppMessages.ShowErrorMessage.Send(e.Message);
                        return;
                    }
                    AppMessages.ShowErrorMessage.Send($"Error while removing Catagory {catagory.Name}");

            });
            ApplyValidationRules();
        }
        public CatagoryAdministrationVM(IAdministrationServices service)
        {
            this.administrationService = service;
            Catagories = new ObservableCollection<CatagoryVM>();
            Add = new RelayCommand((x) =>
            {
                CurrentCatagory = new CatagoryVM(new Catagory(), administrationService);
                Catagories.Add(CurrentCatagory);
                RaisePropertyChangedEvent(nameof(Catagories));
                RaisePropertyChangedEvent(nameof(CurrentCatagory));
            });
            AppMessages.CatagoryChanged.Register(this, (type) =>
            {
                if (type == AppMessages.ChangeType.Remove)
                {
                    this.LoadData();
                }
                RaisePropertyChangedEvent(nameof(Catagories));
                RaisePropertyChangedEvent(nameof(CurrentCatagory));

            });

            this.LoadData();
        }
        public VenueAdministrationVM(IAdministrationServices service)
        {
            this.administrationService = service;
            Venues = new ObservableCollection<VenueVM>();
            Add = new RelayCommand(c =>
            {
                CurrentVenue = new VenueVM(new Venue(), administrationService);
                Venues.Add(CurrentVenue);
                RaisePropertyChangedEvent(nameof(Venues));
                RaisePropertyChangedEvent(nameof(CurrentVenue));
            });

            AppMessages.VenueChanged.Register(this, (type) =>
            {
                if (type == AppMessages.ChangeType.Remove)
                {
                    LoadItems();
                }
                RaisePropertyChangedEvent(nameof(CurrentVenue));
                RaisePropertyChangedEvent(nameof(Venues));
            });

            this.LoadItems();
        }
        public PerformanceVM(Venue v, Performance p1, Performance p2, Performance p3, Performance p4, Performance p5,IAdministrationServices service, PerformanceAdministrationVM parent)
        {
            this.Artists = new ObservableCollection<Artist>();
            this.administrationService = service;
            this.parent = parent;
            venue = v;
            Col1 = p1;
            Col2 = p2;
            Col3 = p3;
            Col4 = p4;
            Col5 = p5;

            this.Artists.Clear();
            IList<Artist> arts = administrationService.GetArtists();
            foreach (Artist artist in arts)
            {
                Artists.Add(artist);
            }

            RemoveEntryCol1 = new RelayCommand(c => {
                Col1.Artist = null;
                RaisePropertyChangedEvent(nameof(ArtistCol1));
                RaisePropertyChangedEvent(nameof(ArtistNameCol1));
                RaisePropertyChangedEvent(nameof(CountryCol1));
                RaisePropertyChangedEvent(nameof(CatagoryCol1));
                RaisePropertyChangedEvent(nameof(ColorCol1));
            });
            RemoveEntryCol2 = new RelayCommand(c => {
                Col2.Artist = null;
                RaisePropertyChangedEvent(nameof(ArtistCol2));
                RaisePropertyChangedEvent(nameof(ArtistNameCol2));
                RaisePropertyChangedEvent(nameof(CountryCol2));
                RaisePropertyChangedEvent(nameof(CatagoryCol2));
                RaisePropertyChangedEvent(nameof(ColorCol2));
            });
            RemoveEntryCol3 = new RelayCommand(c => {
                Col3.Artist = null;
                RaisePropertyChangedEvent(nameof(ArtistCol3));
                RaisePropertyChangedEvent(nameof(ArtistNameCol3));
                RaisePropertyChangedEvent(nameof(CountryCol3));
                RaisePropertyChangedEvent(nameof(CatagoryCol3));
                RaisePropertyChangedEvent(nameof(ColorCol3));
            });
            RemoveEntryCol4 = new RelayCommand(c => {
                Col4.Artist = null;
                RaisePropertyChangedEvent(nameof(ArtistCol4));
                RaisePropertyChangedEvent(nameof(ArtistNameCol4));
                RaisePropertyChangedEvent(nameof(CountryCol4));
                RaisePropertyChangedEvent(nameof(CatagoryCol4));
                RaisePropertyChangedEvent(nameof(ColorCol4));
            });
            RemoveEntryCol5 = new RelayCommand(c => {
                Col5.Artist = null;
                RaisePropertyChangedEvent(nameof(ArtistCol5));
                RaisePropertyChangedEvent(nameof(ArtistNameCol5));
                RaisePropertyChangedEvent(nameof(CountryCol5));
                RaisePropertyChangedEvent(nameof(CatagoryCol5));
                RaisePropertyChangedEvent(nameof(ColorCol5));
            });

            SendEmailCol1 = new RelayCommand(c =>
            {
                IList<Performance> toSend = new List<Performance>();
                toSend.Add(Col1);
                administrationService.SendMail(toSend,toSend);
                AppMessages.ShowSuccessMessage.Send("Mail sent");
            });
            SendEmailCol2 = new RelayCommand(c =>
            {
                IList<Performance> toSend = new List<Performance>();
                toSend.Add(Col2);
                administrationService.SendMail(toSend, toSend);
                AppMessages.ShowSuccessMessage.Send("Mail sent");
            });
            SendEmailCol3 = new RelayCommand(c =>
            {
                IList<Performance> toSend = new List<Performance>();
                toSend.Add(Col3);
                administrationService.SendMail(toSend, toSend);
                AppMessages.ShowSuccessMessage.Send("Mail sent");
            });
            SendEmailCol4 = new RelayCommand(c =>
            {
                IList<Performance> toSend = new List<Performance>();
                toSend.Add(Col4);
                administrationService.SendMail(toSend, toSend);
                AppMessages.ShowSuccessMessage.Send("Mail sent");
            });
            SendEmailCol5 = new RelayCommand(c =>
            {
                IList<Performance> toSend = new List<Performance>();
                toSend.Add(Col5);
                administrationService.SendMail(toSend, toSend);
                AppMessages.ShowSuccessMessage.Send("Mail sent");
            });
        }