public ProfileViewModel(NavigationService navigationService, IRestApiService apiService) { _navigationService = navigationService ?? throw new NullReferenceException(); _apiService = apiService ?? throw new NullReferenceException(); SaveCommand = ReactiveCommand.CreateFromTask(async() => { try { var cont = App.Container.Resolve <ApplicationDataContainer>(); var ret = await _apiService.SetProfileData(new UserDataSettingsDto { Description = this.Description, Job = this.Job, School = this.School }, cont.Values["AuthToken"] as string); Description = ret.Description; Job = ret.Job; School = ret.School; } catch (Exception e) { await new MessageDialog(e.Message).ShowAsync(); } }); DeleteCommand = ReactiveCommand.CreateFromTask(async() => { try { if (SelectedImage == null) { return; } var cont = App.Container.Resolve <ApplicationDataContainer>(); var ret = await _apiService.DeletePhoto(SelectedImage.Id, cont.Values["AuthToken"] as string); SelectedImage = null; var list = new SourceList <PhotoDto>(); list.AddRange(ret); Photos = list; SetMainImage(ret); } catch (Exception e) { await new MessageDialog(e.Message).ShowAsync(); } }); SetMainCommand = ReactiveCommand.CreateFromTask(async() => { try { if (SelectedImage == null) { return; } var cont = App.Container.Resolve <ApplicationDataContainer>(); var ret = await _apiService.SetMainPhoto(SelectedImage.Id, cont.Values["AuthToken"] as string); var list = new SourceList <PhotoDto>(); list.AddRange(ret); Photos = list; SetMainImage(ret); } catch (Exception e) { await new MessageDialog(e.Message).ShowAsync(); } }); }