示例#1
0
        private void UpdateFromModel(Model.Models.Tournament tournament)
        {
            //Set values
            _name        = tournament.Name;
            _startDate   = tournament.StartTime ?? DateTime.Now;
            _description = tournament.Description;
            _maximumMatchDururationInMinutes = tournament.MatchDuration ?? 30;
            _teamCount = Model.TeamCount ?? 16;

            //Raise property changed for values
            RaisePropertyChanged(() => Name);
            RaisePropertyChanged(() => Description);
            RaisePropertyChanged(() => MaximumMatchDurationInMinutes);
            RaisePropertyChanged(() => TeamCount);

            //Raise property changed for calculated values
            RaisePropertyChanged(() => StartDate);
            RaisePropertyChanged(() => StartTime);
            RaisePropertyChanged(() => State);
            RaisePropertyChanged(() => FinalMatch);
            RaisePropertyChanged(() => Matches);
            RaisePropertyChanged(() => HasChanges);
            RaisePropertyChanged(() => TournamentEditable);

            //Raise property changed for commands
            SaveChangesCommand.RaiseCanExecuteChanged();
            StartCommand.RaiseCanExecuteChanged();
            AddTeamCommand.RaiseCanExecuteChanged();
            RemoveTeamCommand.RaiseCanExecuteChanged();
            AddPlayAreaCommand.RaiseCanExecuteChanged();
            RemovePlayAreaCommand.RaiseCanExecuteChanged();
            GenerateWinnerCertificatesCommand.RaiseCanExecuteChanged();
        }
示例#2
0
        private void EventStatusOptionOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            IsDirty = true;

            var option = sender as EventOptionModel;

            if (e.PropertyName == "IsChecked")
            {
                if (option.IsChecked)
                {
                    var eventStatusOption = new EventStatusOption()
                    {
                        ID            = Guid.NewGuid(),
                        EventStatusID = SelectedEventStatus.EventStatus.ID,
                        EventOptionID = option.EventOption.ID
                    };

                    _adminDataUnit.EventStatusOptionsRepository.Add(eventStatusOption);
                }
                else
                {
                    var eventStatusOption = SelectedEventStatus.EventStatus.EventStatusOptions.FirstOrDefault(x => x.EventOptionID == option.EventOption.ID);
                    _adminDataUnit.EventStatusOptionsRepository.Delete(eventStatusOption);
                }

                SaveChangesCommand.RaiseCanExecuteChanged();
            }
        }
示例#3
0
        private void PermissionModelOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            var permission = sender as PermissionModel;

            if (args.PropertyName == "IsChecked")
            {
                IsDirty = true;
                if (permission.IsChecked)
                {
                    var userPermission = new UserPermission()
                    {
                        ID           = Guid.NewGuid(),
                        UserID       = SelectedUser.User.ID,
                        PermissionID = permission.Permission.ID,
                    };

                    _adminDataUnit.UserPermissionsRepository.Add(userPermission);
                }
                else
                {
                    var userPermission =
                        SelectedUser.User.UserPermissions.FirstOrDefault(x => x.PermissionID == permission.Permission.ID);
                    _adminDataUnit.UserPermissionsRepository.Delete(userPermission);
                }

                SaveChangesCommand.RaiseCanExecuteChanged();
            }
        }
 private void RaiseSaveChangesCanExecute()
 {
     if (SaveChangesCommand != null)
     {
         SaveChangesCommand.RaiseCanExecuteChanged();
     }
 }
示例#5
0
        public virtual void Arrange()
        {
            DataSource = new Mock <IDataSource>();

            Command = new SaveChangesCommand(
                DataSource.Object);
        }
示例#6
0
 private void SumColumns()
 {
     SumDugovna  = JournalDetails.Sum(x => x.Dugovna);
     SumPotrazna = JournalDetails.Sum(x => x.Potrazna);
     SumStanje   = SumDugovna - SumPotrazna;
     SidesEqual  = SumStanje == 0;
     SaveChangesCommand.RaiseCanExecuteChanged();
 }
示例#7
0
 protected ViewModelCollection()
 {
     Status         = "Data nebyla načtena";
     RemoveItem     = new RemoveCommand <T>(this);
     SaveNewItem    = new SaveItemCommand <T>(this);
     DiscardNewItem = new DiscardItemCommand <T>(this);
     SaveChanges    = new SaveChangesCommand <T>(this);
     NewItem        = new T();
 }
        public void AllowNextQuestion(QuestionTemplate questionTemplate)
        {
            if (!questionTemplate.Allow)
            {
                return;
            }

            AllowAllInLine(questionTemplate);
            SaveChangesCommand.RaiseCanExecuteChanged();
        }
示例#9
0
 public VMTransaction()
 {
     Transaction = new TransactionClass();
     //Transaction.ChangesSaved += Transaction_ChangesSaved;
     SaveChangesCommand           = new SaveChangesCommand(Transaction);
     DeleteTransactionUserCommand = new RelayCommand(o =>
                                                     Transaction.Transaction.MultiuserManager.DeleteTransactionUser());
     AddTransactionUserCommand = new RelayCommand(o =>
                                                  Transaction.Transaction.MultiuserManager.AddTransactionUser());
 }
示例#10
0
        private void PremissionGroupModelOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            var permissionGroupModel = sender as PermissionGroupModel;

            if (args.PropertyName == "IsChecked")
            {
                IsDirty = true;
                permissionGroupModel.Permissions.ForEach(x => x.IsChecked = permissionGroupModel.IsChecked);
                SaveChangesCommand.RaiseCanExecuteChanged();
            }
        }
示例#11
0
        private async void ResetCommandsAndView()
        {
            LoadHeaders();
            JournalDetails  = null;
            SelectedJournal = null;
            DeleteJournalCommand.RaiseCanExecuteChanged();
            ProcessItemCommand.RaiseCanExecuteChanged();
            SaveChangesCommand.RaiseCanExecuteChanged();

            await Application.Current.Dispatcher.BeginInvoke(new Action(DatagridLoaded), DispatcherPriority.ContextIdle, null);
        }
示例#12
0
 private void RaisePropertiesChanged()
 {
     hasChanged = true;
     RaisePropertyChanged(nameof(DailyWorkTime));
     RaisePropertyChanged(nameof(TotalWorkHours));
     RaisePropertyChanged(nameof(TotalOvertime));
     RaisePropertyChanged(nameof(UnaccountedHours));
     RaisePropertyChanged(nameof(WorkItems));
     RaisePropertyChanged(nameof(IsMobileOffice));
     SaveChangesCommand.RaiseCanExecuteChanged();
     EditWorkItemCommand.RaiseCanExecuteChanged();
 }
示例#13
0
 internal void Close(bool askSaveChanges)
 {
     if (HasChanges && askSaveChanges)
     {
         MessengerInstance.Send(new AreYouSureMessage("Änderungen", "Sollen die Änderungen gespeichert werden?", () =>
         {
             //Save changes
             SaveChangesCommand.Execute(null);
         }));
     }
     MessengerInstance.Send(new CloseTournamentMessage(this));
 }
示例#14
0
        private void InitActions()
        {
            AddModCommand = new AddModelCommand <ModItemViewModel>(Mods, new ModItemViewModel(new Mod(), this), ActionsManager);
            AddModCommand.CommandExecuted += ((cmd, param) =>
            {
                SelectedMod = param;
                Status.IsProgressVisible = false;
                Status.Status = string.Format("Added mod with ID = {0}", SelectedMod.Mod.ID);
            });

            DeleteModCommand    = new DeleteModelCommand <ModItemViewModel>(Mods, ActionsManager);
            CheckAllModsCommand = new CheckAllModsCommand(this);
            SaveChangesCommand  = new SaveChangesCommand();
        }
示例#15
0
 private void Start()
 {
     if (PlayAreas.Count == 0)
     {
         MessengerInstance.Send(new NoPlayAreaDefinedMessage());
         return;
     }
     if (TeamCount != Teams.Count())
     {
         MessengerInstance.Send(new TeamCountMismatchMessage(Model.Id.Value, Teams.Count, TeamCount));
         return;
     }
     if (HasChanges)
     {
         bool abortStart = true;
         MessengerInstance.Send(new AreYouSureMessage("Ungespeicherte Änderungen", "Es gibt noch ungespeicherte Änderungen.\nDiese müssen gespeichert werden vor dem Start.\nWollen Sie jetzt speichern und fortfahren?", () =>
         {
             abortStart = false;
         }));
         if (abortStart)
         {
             return;
         }
         SaveChangesCommand.Execute(null);
     }
     try
     {
         var resp = App.RestClient.StartWithHttpMessagesAsync(Id);
         resp.ContinueWith(t =>
         {
             Model = resp.Result.Body;
             UpdateFromModel(Model);
         }
                           );
     }
     catch (Exception e)
     {
         if (e.GetType() == typeof(AggregateException) || e.GetType() == typeof(Microsoft.Rest.HttpOperationException))
         {
             MessengerInstance.Send(new CommunicationErrorMessage());
         }
         else
         {
             throw e;
         }
     }
     // Alle Properties => RaisePropertyChanged / Command.CanExecute updaten
 }
        private void SetPassword(object parameter)
        {
            var passwords = parameter as PasswordBox[];

            if (passwords == null)
            {
                return;
            }

            if (Settings.IsMasterPasswordSet)
            {
                string currentPassword = Hashing.EncryptString(passwords[2].Password);
                string storedPassword  = Settings.WindowOpen;
                if (storedPassword == null)
                {
                    Settings.IsMasterPasswordSet = false;
                    SettingsChanging();
                    SaveChangesCommand.Execute(null);
                    return;
                }
                if (currentPassword != storedPassword)
                {
                    windowService.ShowMessageDialog("Wrong current password.", false);
                    return;
                }
            }
            string password        = passwords[0].Password;
            string confirmPassword = passwords[1].Password;

            if (password != confirmPassword)
            {
                windowService.ShowMessageDialog("Passwords don't match", false);
                return;
            }
            if (!string.IsNullOrEmpty(password.Trim()))
            {
                Settings.IsMasterPasswordSet = true;
                Settings.WindowOpen          = Hashing.EncryptString(password);
                windowService.ShowMessageDialog("Password set.", false);
            }
            else
            {
                Settings.IsMasterPasswordSet = false;
                Settings.WindowOpen          = "";
            }
            SettingsChanging();
            SaveChangesCommand.Execute(null);
        }
示例#17
0
        private void SelectedWorkChanged(object sender, PropertyChangedEventArgs e)
        {
            var work = sender as StoreProvenWorkSet;

            if (work != null)
            {
                if (!ChangedWorkList.Contains(work))
                {
                    ChangedWorkList.Add(work);
                }
                else
                {
                    ChangedWorkList.Remove(work);
                }
                SaveChangesCommand.RaiseCanExecuteChanged();
            }
        }
示例#18
0
        private void InitializeCommands()
        {
            NewProjectCommand              = new NewProjectCommand(this);
            SaveChangesCommand             = new SaveChangesCommand(this);
            RemoveSelectedNewActionCommand = new RemoveSelectedNewActionCommand(this);
            OpenFileCommand             = new OpenFileCommand(this);
            ExecuteActionCommand        = new ExecuteActionCommand(this);
            OpenAddActionDialogCommand  = new OpenAddActionDialogCommand(this);
            CloseAddActionDialogCommand = new CloseAddActionDialogCommand(this);

            RegisterCommand(NewProjectCommand);
            RegisterCommand(SaveChangesCommand);
            RegisterCommand(RemoveSelectedNewActionCommand);
            RegisterCommand(OpenFileCommand);
            RegisterCommand(ExecuteActionCommand);
            RegisterCommand(OpenAddActionDialogCommand);
            RegisterCommand(CloseAddActionDialogCommand);

            RaiseCanExecuteCommandChanged();
        }
示例#19
0
        public void EditUserPasswordCommandExecuted()
        {
            string password = string.Empty;

            RaisePropertyChanged("DisableParentWindow");

            RadWindow.Prompt(new DialogParameters()
            {
                Content = "Enter New Password:"******"EnableParentWindow");

            if (!string.IsNullOrWhiteSpace(password))
            {
                SelectedUser.User.PasswordSalt = Guid.NewGuid().ToString("N");
                SelectedUser.User.PasswordHash = _saltedHash.ComputeHash(password + SelectedUser.User.PasswordSalt);
            }

            //_adminDataUnit.SaveChanges();
            SaveChangesCommand.RaiseCanExecuteChanged();
        }
 private void CanExecuteChanged()
 {
     SaveChangesCommand.RaiseCanExecuteChanged();
     AddAnswerCommand.RaiseCanExecuteChanged();
     RaisePropertyChanged(nameof(SelectedQuestion));
 }
 protected override void OnInnerItemChangedUI()
 {
     SaveChangesCommand.RaiseCanExecuteChanged();
 }
 private void UpdateCommands()
 {
     RemoveCommand.RaiseCanExecuteChanged();
     SaveChangesCommand.RaiseCanExecuteChanged();
 }
示例#23
0
        public ConnectionInfoManagementViewModel()
        {
            AddNewItemCommand = IsItemEditing.Inverse().ToReactiveCommand();
            AddNewItemCommand.Subscribe(() =>
            {
                SelectedItem.Value = null;
                EditingItem.Value  = new T();
                if (IsGroupSelected?.Value == true)
                {
                    EditingItem.Value.GroupName = SelectedGroup.Value?.Name;
                }
                IsItemEditing.Value = true;
            }).AddTo(Disposable);

            ConnectCommand.Subscribe(async item => await ConfirmConnect(item)).AddTo(Disposable);

            IsItemSelected = SelectedItem.Select(x => x != null).ToReadOnlyReactiveProperty();

            IsNotItemEditing = IsItemEditing.Inverse().ToReadOnlyReactiveProperty();

            SelectedItem.Subscribe(x =>
            {
                EditingItem.Value   = SelectedItem.Value;
                IsItemEditing.Value = false;
            }).AddTo(Disposable);

            StartEditCommand = IsItemSelected
                               .CombineLatest(IsItemEditing.Inverse(), (a, b) => a && b)
                               .ToReactiveCommand();
            StartEditCommand.Subscribe(() =>
            {
                EditingItem.Value   = SelectedItem.Value.CloneDeep();
                IsItemEditing.Value = true;
            }).AddTo(Disposable);

            ReplicateCommand = IsItemSelected
                               .CombineLatest(IsItemEditing.Inverse(), (a, b) => a && b)
                               .ToReactiveCommand();
            ReplicateCommand.Subscribe(() =>
            {
                var replicated      = SelectedItem.Value.CloneDeep();
                replicated.Id       = -1;
                SelectedItem.Value  = null;
                EditingItem.Value   = replicated;
                IsItemEditing.Value = true;
            }).AddTo(Disposable);

            RemoveCommand = IsItemSelected
                            .CombineLatest(IsItemEditing.Inverse(), (a, b) => a && b)
                            .ToAsyncReactiveCommand();
            RemoveCommand.Subscribe(async() =>
            {
                if (await Remove(SelectedItem.Value))
                {
                    Items.Remove(SelectedItem.Value);
                    // Renew Windows JumpList
                    JumpListHelper.RenewJumpList(await MainWindow.DbContext.EnumerateAllConnectionInfos());
                }
            }).AddTo(Disposable);

            DiscardChangesCommand = IsItemEditing.ToReactiveCommand();
            DiscardChangesCommand.Subscribe(() =>
            {
                EditingItem.Value   = SelectedItem.Value ?? new T();
                IsItemEditing.Value = false;
            }).AddTo(Disposable);

            SaveChangesCommand = IsItemEditing.ToReactiveCommand();
            SaveChangesCommand.Subscribe(async() =>
            {
                var selectedItem = SelectedItem.Value;
                var item         = EditingItem.Value;
                try
                {
                    var(result, resultItem) = await Save(item);
                    if (resultItem == null)
                    {
                        return;        // FAILED
                    }
                    item = resultItem; // Replace with the saved item
                    if (result)        // ADDED
                    {
                        Items.Add(item);
                    }
                    else // UPDATED
                    {
                        var oldItem = Items.FirstOrDefault(x => x.Id == item.Id);
                        if (oldItem != null)
                        {
                            var index = Items.IndexOf(oldItem);
                            if (index >= 0)
                            {
                                Items.RemoveAt(index);
                                Items.Insert(index, item);
                            }
                        }
                    }
                    // Renew Windows JumpList
                    JumpListHelper.RenewJumpList(await MainWindow.DbContext.EnumerateAllConnectionInfos());
                }
                catch (OperationCanceledException) // User manually canceled
                {
                    return;
                }
                SelectedItem.Value  = item;
                IsItemEditing.Value = false;
            }).AddTo(Disposable);

            // Connection info filterings
            FilterText
            .Throttle(TimeSpan.FromMilliseconds(500))
            .ObserveOnDispatcher()
            .Subscribe(_ => RefreshCollectionView())
            .AddTo(Disposable);
            SelectedGroup
            .ObserveOnDispatcher()
            .Subscribe(_ => RefreshCollectionView())
            .AddTo(Disposable);

            // If any group is selected or not (except for "All")
            IsGroupSelected = SelectedGroup
                              .Select(x => x?.Name != AllGroupName)
                              .ToReadOnlyReactivePropertySlim()
                              .AddTo(Disposable);

            // Group list extraction on connection info events
            Observable.CombineLatest(
                // When Add, Remove or Update
                Items.CollectionChangedAsObservable()
                .Select(_ => Unit.Default)
                .StartWith(Unit.Default),
                // When GroupName property in each element changed
                Items.ObserveElementPropertyChanged()
                .Where(x => x.EventArgs.PropertyName == nameof(ConnectionInfoBase.GroupName))
                .Select(_ => Unit.Default)
                .StartWith(Unit.Default)
                )
            .Throttle(TimeSpan.FromMilliseconds(500))     // Once 500 ms
            .ObserveOnDispatcher()
            .Subscribe(_ =>
            {
                var selectedGroup = SelectedGroup.Value;
                // Reload group list
                Groups.Clear();
                EnumerateGroups().ToList().ForEach(Groups.Add);
                // Reset selected group
                SelectedGroup.Value = (selectedGroup is null) ? Groups.FirstOrDefault() : selectedGroup;
            })
            .AddTo(Disposable);
        }
示例#24
0
 public override void OnNavigatedTo(NavigationContext navigationContext)
 {
     NewWork = new StoreProvenWorkSet();
     SaveChangesCommand.RaiseCanExecuteChanged();
     _worker.RunWorkerAsync();
 }
示例#25
0
        public ProfileViewModel(IParentService parentService, IUserDialogs userDialogs,
                                IMvxMessenger mvxMessenger, AppHelper appHelper) : base(userDialogs, mvxMessenger, appHelper)
        {
            _parentService = parentService;

            SaveChangesCommand = ReactiveCommand.CreateFromObservable <Unit, ParentEntity>((param) =>
            {
                return(NewProfileImage != null ?
                       _parentService.UploadProfileImage(NewProfileImage.GetStream())
                       .SelectMany((_) => _parentService.Update(SelfParent.FirstName, SelfParent.LastName, SelfParent.Birthdate, SelfParent.Email, string.Concat(SelfParent.PhonePrefix, SelfParent.PhoneNumber))) :

                       _parentService.Update(SelfParent.FirstName, SelfParent.LastName, SelfParent.Birthdate, SelfParent.Email, string.Concat(SelfParent.PhonePrefix, SelfParent.PhoneNumber)));
            });


            SaveChangesCommand.Subscribe(AccountUpdatedHandler);

            SaveChangesCommand.IsExecuting.Subscribe((IsLoading) => HandleIsExecuting(IsLoading, AppResources.Profile_Save_Changes));

            SaveChangesCommand.ThrownExceptions.Subscribe(HandleExceptions);

            RefreshCommand = ReactiveCommand.CreateFromObservable <Unit, ParentEntity>((param) => _parentService.GetProfileInformation());

            RefreshCommand.Subscribe((ParentEntity) => {
                SelfParent.HydrateWith(ParentEntity);
                ResetCommonProps();
                IsDirtyMonitoring = true;
            });

            RefreshCommand.IsExecuting.Subscribe((IsLoading) => HandleIsExecuting(IsLoading, AppResources.Profile_Loading_Data));

            RefreshCommand.ThrownExceptions.Subscribe(HandleExceptions);

            DeleteAccountCommand = ReactiveCommand
                                   .CreateFromObservable <Unit, string>((param) =>
            {
                return(Observable.FromAsync <bool>((_) => _userDialogs.ConfirmAsync(new ConfirmConfig()
                {
                    Title = AppResources.Profile_Confirm_Account_Deleting
                })).Where((confirmed) => confirmed).Do((_) => HandleIsExecuting(true, AppResources.Profile_Account_Deleting))
                       .SelectMany((_) => _parentService.DeleteAccount())
                       .Do((_) => HandleIsExecuting(false, AppResources.Profile_Account_Deleting)));
            });


            DeleteAccountCommand.Subscribe((_) =>
            {
                Bullytect.Core.Config.Settings.AccessToken = null;
                ShowViewModel <AuthenticationViewModel>(new AuthenticationViewModel.AuthenticationParameter()
                {
                    ReasonForAuthentication = AuthenticationViewModel.ACCOUNT_DELETED
                });
            });


            DeleteAccountCommand.ThrownExceptions.Subscribe(HandleExceptions);


            TakePhotoCommand = ReactiveCommand.CreateFromObservable <Unit, MediaFile>((_) => appHelper.PickPhotoStream());


            TakePhotoCommand.Subscribe((ImageStream) => {
                _userDialogs.HideLoading();
                NewProfileImage = ImageStream;
                OnNewSelectedImage(ImageStream);
            });

            TakePhotoCommand.ThrownExceptions.Subscribe(HandleExceptions);
        }
示例#26
0
 private void MemberModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     SaveChangesCommand.RaiseCanExecuteChanged();
 }
示例#27
0
        public EditSonViewModel(IUserDialogs userDialogs, IMvxMessenger mvxMessenger, IParentService parentService,
                                ISocialMediaService socialMediaService, AppHelper appHelper, IOAuthService oauthService, ISchoolService schoolService) : base(userDialogs, mvxMessenger, appHelper)
        {
            _parentService      = parentService;
            _socialMediaService = socialMediaService;
            _schoolService      = schoolService;
            _oauthService       = oauthService;


            RefreshCommand = ReactiveCommand.CreateFromObservable <Unit, PageModel>((param) => !PageLoaded ? LoadPageModel(): Observable.Empty <PageModel>());

            RefreshCommand.Subscribe(OnPageModelLoaded);

            RefreshCommand.IsExecuting.Subscribe((isExecuting) => HandleIsExecuting(isExecuting, AppResources.Common_Loading));

            RefreshCommand.ThrownExceptions.Subscribe(HandleExceptions);

            ForceRefreshCommand = ReactiveCommand.CreateFromObservable <Unit, PageModel>((param) => LoadPageModel());

            ForceRefreshCommand.Subscribe(OnPageModelLoaded);

            ForceRefreshCommand.IsExecuting.Subscribe((isExecuting) => HandleIsExecuting(isExecuting, AppResources.Common_Loading));

            ForceRefreshCommand.ThrownExceptions.Subscribe(HandleExceptions);

            TakePhotoCommand = ReactiveCommand.CreateFromObservable <Unit, MediaFile>((param) => _appHelper.PickPhotoStream());

            TakePhotoCommand.Subscribe((ImageFile) =>
            {
                _userDialogs.HideLoading();
                NewProfileImage = ImageFile;
                OnNewSelectedImage(ImageFile);
            });

            TakePhotoCommand.ThrownExceptions.Subscribe(HandleExceptions);


            SaveChangesCommand = ReactiveCommand
                                 .CreateFromObservable <Unit, bool>((param) =>
            {
                return((CurrentSon.Identity == null ?
                        _parentService.AddSonToSelfParent(CurrentSon.FirstName, CurrentSon.LastName, CurrentSon.Birthdate, CurrentSon.School.Identity) :
                        _parentService.UpdateSonInformation(CurrentSon.Identity, CurrentSon.FirstName, CurrentSon.LastName, CurrentSon.Birthdate, CurrentSon.School.Identity))
                       .Do((SonEntity) => CurrentSon.HydrateWith(SonEntity))
                       .SelectMany((SonEntity) => _socialMediaService
                                   .SaveAllSocialMedia(
                                       CurrentSon.Identity,
                                       CurrentSocialMedia.Select(s => { s.Son = CurrentSon.Identity; return s; }).ToList()
                                       ).Catch <IList <SocialMediaEntity>, NoSocialMediaFoundException>(ex => Observable.Return(new List <SocialMediaEntity>()))
                                   )
                       .Do((SocialMediaEntities) => CurrentSocialMedia.ReplaceRange(SocialMediaEntities))

                       .SelectMany((_) =>
                {
                    return NewProfileImage != null ?
                    _parentService.UploadSonProfileImage(CurrentSon.Identity, NewProfileImage.GetStream()) :
                    Observable.Empty <ImageEntity>();
                })
                       .Select((_) => true)
                       .DefaultIfEmpty(true));
            });

            SaveChangesCommand.Subscribe((_) =>
            {
                NewProfileImage = null;
                OnSonUpdated(CurrentSon);
                _userDialogs.ShowSuccess(AppResources.EditSon_Saved_Changes_Successfully);
                IsDirtyMonitoring = true;
            });

            SaveChangesCommand.IsExecuting.Subscribe((isLoading) => HandleIsExecuting(isLoading, AppResources.EditSon_Saving_Changes));

            SaveChangesCommand.ThrownExceptions.Subscribe(HandleExceptions);

            SaveSchoolCommand = ReactiveCommand.CreateFromObservable <Unit, SchoolEntity>((param) => _schoolService.CreateSchool(NewSchool.Name, NewSchool.Residence, NewSchool.Latitude, NewSchool.Longitude, NewSchool.Province, NewSchool.Tfno, NewSchool.Email));

            SaveSchoolCommand.Subscribe((SchoolAdded) =>
            {
                NewSchool = new SchoolEntity();
                CurrentSon.School.HydrateWith(SchoolAdded);
                _appHelper.ShowAlert(AppResources.EditSon_School_Saved);
                OnSchoolAdded(SchoolAdded);
            });


            SaveSchoolCommand.IsExecuting.Subscribe((isLoading) => HandleIsExecuting(isLoading, AppResources.EditSon_Saving_School));

            SaveSchoolCommand.ThrownExceptions.Subscribe(HandleExceptions);


            FindSchoolsCommand = ReactiveCommand.CreateFromObservable <string, IList <SchoolEntity> >(
                (name) => _schoolService.FindSchools(name));

            FindSchoolsCommand.IsExecuting.Subscribe((isLoading) => HandleIsExecuting(isLoading, AppResources.EditSon_Find_School));

            FindSchoolsCommand.ThrownExceptions.Subscribe(HandleExceptions);

            FindSchoolsCommand.Subscribe((SchoolsFounded) => {
                SearchPerformed = true;
                Schools.ReplaceRange(SchoolsFounded);
            });
        }