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();
        }
Example #2
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();
        }