public SendViewModel() { chatService = ServiceLocator.Current.GetInstance<IChatService>(); parentViewModel = ServiceLocator.Current.GetInstance<CameraViewModel>(); parentViewModel.PropertyChanged += parentViewModel_PropertyChanged; ResetImageSource(); SendPhoto = new RelayCommand(async () => { PhotoRecord p = new PhotoRecord(); // If they didn't explicitly toggle the list picker, assume // they want the first contact in the list. if (SelectedFriend != null) { p.RecepientUserId = SelectedFriend.UserId; } else { p.RecepientUserId = Friends.First().UserId; } p.SenderUserId = App.CurrentUser.UserId; p.SenderName = App.CurrentUser.Name; await chatService.CreatePhotoRecordAsync(p); System.Net.Http.HttpResponseMessage m = await chatService.UploadPhotoAsync(p.Uri, p.UploadKey, parentViewModel.Image); App.RootFrame.Navigate(new Uri("/View/PhotosPage.xaml", UriKind.RelativeOrAbsolute)); }); RefreshCommand = new RelayCommand(async () => { Friends = await chatService.ReadFriendsAsync(App.CurrentUser.UserId); }); }
public SendViewModel() { chatService = ServiceLocator.Current.GetInstance <IChatService>(); parentViewModel = ServiceLocator.Current.GetInstance <CameraViewModel>(); parentViewModel.PropertyChanged += parentViewModel_PropertyChanged; ResetImageSource(); SendPhoto = new RelayCommand(async() => { PhotoRecord p = new PhotoRecord(); // If they didn't explicitly toggle the list picker, assume // they want the first contact in the list. if (SelectedFriend != null) { p.RecepientUserId = SelectedFriend.UserId; } else { p.RecepientUserId = Friends.First().UserId; } p.SenderUserId = App.CurrentUser.UserId; p.SenderName = App.CurrentUser.Name; await chatService.CreatePhotoRecordAsync(p); System.Net.Http.HttpResponseMessage m = await chatService.UploadPhotoAsync(p.Uri, p.UploadKey, parentViewModel.Image); App.RootFrame.Navigate(new Uri("/View/PhotosPage.xaml", UriKind.RelativeOrAbsolute)); }); RefreshCommand = new RelayCommand(async() => { Friends = await chatService.ReadFriendsAsync(App.CurrentUser.UserId); }); }