public async override void Prepare()
        {
            DogShowList = await _dogShowService.GetDogShowListAsync <DogShowDetail>();

            var data = await _dogRegistrationService.GetListAsync <DogRegistrationDetail>();

            var orderedData = from d in data
                              orderby d.RegisrationNumber ascending
                              select d;

            DogRegistrations = orderedData.ToList();

            HandlerClasses = await _handlerClassService.GetHandlerClassListAsync <HandlerClassEntity>();

            CurrentEntity = new MultipleHandlerEntry();
            foreach (IDogShowEntity dogShow in DogShowList)
            {
                HandlerEntry newEntry = new HandlerEntry();
                newEntry.DogShow = dogShow;
                newEntry.Handler = SelectedHandlerRegistration;

                (CurrentEntity as MultipleHandlerEntry).HandlerEntries.Add(newEntry);
                (CurrentEntity as MultipleHandlerEntry).NotifyEntriesChanged();
            }
        }
Example #2
0
    public static void SetGeneralError(this ValidatableBindableBase model, Exception ex)
    {
        if (model == null)
        {
            throw new ArgumentNullException(nameof(model));
        }

        model.SetGeneralError(ex.ToStringDemystified());
    }
Example #3
0
        protected virtual async Task PerformSave(ValidatableBindableBase currentEntity)
        {
            U entity = currentEntity as U;

            if (entity == null)
            {
                throw new Exception(string.Format("Cannot save entity because it is of type {0}", currentEntity.GetType()));
            }

            await _entityUpdateService.UpdateEntityAsync(entity);
        }
        protected virtual async Task <int> PerformSaveAndGetIDBack(ValidatableBindableBase currentEntity)
        {
            int newId = -1;

            U entity = currentEntity as U;

            if (entity == null)
            {
                throw new Exception(string.Format("Cannot save entity because it is of type {0}", currentEntity.GetType()));
            }

            newId = await _entityCreateService.CreateEntityAsync(entity);

            return(newId);
        }
 public ScheduleCreatorViewModel()
 {
     _propGridLG         = WinHueSettings.settings.UsePropertyGrid;
     ListTargetHueObject = new ObservableCollection <IHueObject>();
     _header             = new ScheduleCreatorHeader();
     _content            = ContentTypeVm.Light;
     _effect             = "none";
     _dateTimeFormat     = "yyyy-MM-ddTHH:mm:ss";
     _smask = "000";
     if (_propGridLG)
     {
         _selectedViewModel = new ScheduleCreatorPropertyGridViewModel();
     }
     else
     {
         _selectedViewModel = new ScheduleCreatorSlidersViewModel();
     }
 }
        public async void ExecuteCommand(IEntityAwareViewViewModel viewModel)
        {
            ValidatableBindableBase entity = viewModel.CurrentEntity;

            IDirtyAwareEntity dirtyAwareEntity = (entity as IDirtyAwareEntity);

            if (dirtyAwareEntity != null)
            {
                if (dirtyAwareEntity.IsDirty)
                {
                    MessageDialogResult dialogResult;
                    var mySettings = new MetroDialogSettings()
                    {
                        AffirmativeButtonText = "Yes, I want to cancel this action",
                        NegativeButtonText    = "No, I changed my mind",
                        MaximumBodyHeight     = 100,
                        ColorScheme           = MetroDialogColorScheme.Accented
                    };

                    MetroWindow metroWindow = Application.Current.MainWindow as MetroWindow;
                    dialogResult = await metroWindow.ShowMessageAsync("CONFIRM ACTION", "You are about to move away without saving.  Are you sure you want to cancel the current action?",
                                                                      MessageDialogStyle.AffirmativeAndNegative, mySettings);

                    if (dialogResult == MessageDialogResult.Affirmative)
                    {
                        NavigateBack(viewModel);
                    }
                }
                else
                {
                    NavigateBack(viewModel);
                }
            }
            else
            {
                NavigateBack(viewModel);
            }
        }
 public override void GetValuesFromNavigationParameters(NavigationContext navigationContext)
 {
     CurrentEntity = navigationContext.Parameters["entity"] as ValidatableBindableBase;
 }
Example #8
0
 public static void SetGeneralError(this ValidatableBindableBase model, string error)
 {
     model.SetAllErrors(
         new Dictionary <string, ReadOnlyCollection <string> >
     {
 public override void Prepare()
 {
     CurrentEntity = new DogShowDetail();
 }
 public CouldNotSaveNewEntityException(ValidatableBindableBase newEntity)
     : base("Could not save new entity")
 {
     NewEntity = newEntity;
 }
 public ScheduleCreatorViewModel()
 {
     _header            = new ScheduleCreatorHeader();
     _selectedViewModel = new ScheduleCreatorSlidersViewModel();
 }