public async Task SaveBlobImageAsync(StoragePictureModel model) { var uri = new Uri(model.PictureStorageSASToken.Trim('\"')); CloudBlobContainer container = new CloudBlobContainer(uri); CloudBlockBlob blob = container.GetBlockBlobReference(model.UserID + ".jpg"); await blob.UploadFromByteArrayAsync(model.UserPicture, 0, model.UserPicture.Length); }
public async Task GetBlobImageAsync(StoragePictureModel model) { try { var uri = new Uri(model.PictureStorageSASToken.Trim('\"')); CloudBlobContainer container = new CloudBlobContainer(uri); CloudBlockBlob blob = container.GetBlockBlobReference(model.UserID + ".jpg"); using (var msRead = new MemoryStream()) { msRead.Position = 0; using (msRead) { await blob.DownloadToStreamAsync(msRead); } msRead.Flush(); model.UserPicture = msRead.GetBuffer(); } } //TODO:Catch Specific catch (Exception excp) { OnError?.Invoke(new string[] { excp.Message }); } }
private async Task <List <ContactModel> > SelectContactsWithRole(RegisterViewModel model, List <DynamixContact> contacts, string role) { if (contacts != null) { var query = from source in contacts.Where(a => a.connectedRole.roleName == role) select new ContactModel { UserID = source.userId, ConnectionId = source.connectionId, ContactRole = source.connectedRole.roleName, FirstName = source.firstName, LastName = source.lastName, PictureURL = source.profileImage, }; var contactModels = query.ToList(); foreach (var contact in contactModels) { var storagePictureModel = new StoragePictureModel { TokenID = model.TokenID, UserID = contact.UserID, PictureStorageSASToken = model.PictureStorageSASToken }; await BlobStorageRepository.GetBlobImageAsync(storagePictureModel); contact.UserPicture = storagePictureModel.UserPicture; } return(contactModels); } return(null); }
public async Task StoreSelfieAsync(StoragePictureModel model) { try { await _StorageRepository.SaveBlobImageAsync(model); } catch (Exception excp) { OnError?.Invoke(new string[] { excp.Message }); } }
public StoragePictureModel GetStoragePictureModelForSelfie(byte[] contactPicture, string userID) { var myModel = new StoragePictureModel { TokenID = _MasterRepo.DataSource.User.TokenID, UserID = userID, UserPicture = contactPicture, PictureStorageSASToken = _MasterRepo.DataSource.User.PictureStorageSASToken }; return(myModel); }
internal async Task <ContactModel> GetDefaultBeneficiaryAsync() { var source = await ContactStorageRepository.GetDefaultBeneficiaryAsync(); if (source != null) { var model = new StoragePictureModel { TokenID = DataSource.User.TokenID, UserID = DataSource.User.UserID, PictureStorageSASToken = DataSource.User.PictureStorageSASToken }; await BlobStorageRepository.GetBlobImageAsync(model); source.UserPicture = model.UserPicture; } return(source); }
internal async Task <List <ContactModel> > GetTrustedSourcesAsync() { var dbTrustedSources = await ContactStorageRepository.GetTrustedSourcesAsync(); if (dbTrustedSources != null && dbTrustedSources.Count == 3) { foreach (var source in dbTrustedSources) { if (source.UserPicture == null) { var model = new StoragePictureModel { TokenID = DataSource.User.TokenID, UserID = DataSource.User.UserID, PictureStorageSASToken = DataSource.User.PictureStorageSASToken }; await BlobStorageRepository.GetBlobImageAsync(model); source.UserPicture = model.UserPicture; } } } return(dbTrustedSources); }
public async Task GetSelfieAsync(StoragePictureModel model) { await _StorageRepository.GetBlobImageAsync(model); }