public SonProfileViewModel(IUserDialogs userDialogs, IMvxMessenger mvxMessenger, AppHelper appHelper, IParentService parentService, IStatisticsService statisticsService) : base(userDialogs, mvxMessenger, appHelper) { _parentService = parentService; _statisticsService = statisticsService; DeleteSonCommand = ReactiveCommand .CreateFromObservable(() => _appHelper.RequestConfirmation(AppResources.Son_Profile_Delete_Confirm) .SelectMany((confirmed) => confirmed ? _parentService.DeleteSonById(Identity) : Observable.Empty <string>()) .Do((_) => Close(this))); DeleteSonCommand.IsExecuting.Subscribe((isLoading) => HandleIsExecuting(isLoading, AppResources.Common_Loading)); DeleteSonCommand.ThrownExceptions.Subscribe(HandleExceptions); RefreshCommand = ReactiveCommand.CreateFromObservable <Unit, PageModel>((_) => Observable.Zip( _parentService.GetSonById(Identity), _statisticsService.GetDimensionsStatistics(Identity, 1).OnErrorResumeNext(Observable.Return(new ChartModel())), (SonEntity SonInformation, ChartModel ChartModel) => new PageModel() { SonEntity = SonInformation, DimensionChart = ChartModel })); RefreshCommand.IsExecuting.Subscribe((IsLoading) => IsBusy = IsLoading); RefreshCommand.Subscribe((PageModel) => { ResetCommonProps(); SonEntity.HydrateWith(PageModel.SonEntity); if (PageModel.DimensionChart.Entries?.Count > 0) { FourDimensionsChart = PageModel.DimensionChart; } else { DataFound = false; } }); RefreshCommand.ThrownExceptions.Subscribe(HandleExceptions); }
void ViewModel_OnOnSonUpdatedAsync(Object sender, SonEntity SonEntity) { profileImage.ReloadImage(); }