Beispiel #1
0
        public Task CreatePhotoRecordAsync(PhotoRecord record)
        {
            PhotoContent content = new PhotoContent();

            content.SecretId = Guid.NewGuid().ToString();
            content.Uri      = new Uri(String.Format("http://{0}", Guid.NewGuid()));
            photoContents[content.SecretId] = content;
            content.Id = photoContents.Count - 1;

            photoRecords.Add(record);
            record.Id                   = photoRecords.IndexOf(record);
            record.Sent                 = DateTimeOffset.Now;
            record.SenderName           = App.CurrentUser.Name;
            record.SenderUserId         = App.CurrentUser.UserId;
            record.PhotoContentSecretId = content.SecretId;
            record.Expired              = false;

            // These two are returned but not stored in the
            // datastore, we delete them later
            record.UploadKey = String.Empty; // Doesn't matter in this case
            record.Uri       = content.Uri;

            content.PhotoRecordId = record.Id;

            return(Task.FromResult(0));
        }
Beispiel #2
0
        public Task <ObservableCollection <PhotoContent> > ReadPhotoContentAsync(string id)
        {
            PhotoContent content = null;

            if (photoContents.TryGetValue(id, out content))
            {
                PhotoRecord record = photoRecords[content.PhotoRecordId];
                record.Received = DateTimeOffset.Now;
            }

            ObservableCollection <PhotoContent> wrapper = new ObservableCollection <PhotoContent>();

            wrapper.Add(content);
            return(Task.FromResult <ObservableCollection <PhotoContent> >(wrapper));
        }
Beispiel #3
0
        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 async Task CreatePhotoRecordAsync(PhotoRecord record)
 {
     await recordsTable.InsertAsync(record);
 }
Beispiel #5
0
        public Task CreatePhotoRecordAsync(PhotoRecord record)
        {
            PhotoContent content = new PhotoContent();
            content.SecretId = Guid.NewGuid().ToString();
            content.Uri = new Uri(String.Format("http://{0}", Guid.NewGuid()));
            photoContents[content.SecretId] = content;
            content.Id = photoContents.Count - 1;

            photoRecords.Add(record);
            record.Id = photoRecords.IndexOf(record);
            record.Sent = DateTimeOffset.Now;
            record.SenderName = App.CurrentUser.Name;
            record.SenderUserId = App.CurrentUser.UserId;
            record.PhotoContentSecretId = content.SecretId;
            record.Expired = false;

            // These two are returned but not stored in the
            // datastore, we delete them later
            record.UploadKey = String.Empty; // Doesn't matter in this case
            record.Uri = content.Uri;

            content.PhotoRecordId = record.Id;

            return Task.FromResult(0);
        }
Beispiel #6
0
 public async Task CreatePhotoRecordAsync(PhotoRecord record)
 {
     await recordsTable.InsertAsync(record);
 }