This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task Create(MyContact myContact) | |
{ | |
//create the Exchange contact | |
IContact contact = new Contact(); | |
contact.GivenName = myContact.Name; | |
contact.DisplayName = myContact.Name; | |
contact.EmailAddress1 = myContact.Email; | |
contact.JobTitle = myContact.JobTitle; | |
//add the contact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<ObservableCollection<MyContact>> GetContacts() | |
{ | |
ObservableCollection<MyContact> myContactList = new ObservableCollection<MyContact>(); | |
//query contacts | |
var contactsResults = await _exchangeClient.Me.Contacts.OrderBy(c=>c.DisplayName).ExecuteAsync(); | |
//fetches the first 50 contacts | |
//default page count is 50 | |
var contacts = contactsResults.CurrentPage.ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<byte[]> GetContactImage(string strContactId) | |
{ | |
byte[] bytesContactPhoto = new byte[0]; | |
//query the contact by contact Id | |
//GetById is broken so you need to use this instead | |
var contact = await _exchangeClient.Me.Contacts[strContactId].ExecuteAsync(); | |
if (contact != null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<bool> Update(MyContact myContact) | |
{ | |
bool bStatus = false; | |
//myContact is my business object | |
//query the contact by contact Id | |
//GetById is broken so you need to use this instead | |
var contact = await _exchangeClient.Me.Contacts[myContact.Id].ExecuteAsync(); | |
if (contact != null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<bool> Delete(string strContactId) | |
{ | |
bool bStatus = false; | |
//query the contact by contact Id | |
//GetById is broken so you need to use this instead | |
var contact = await _exchangeClient.Me.Contacts[strContactId].ExecuteAsync(); | |
if (contact != null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<ObservableCollection<MyFile>> GetMyFiles() | |
{ | |
ObservableCollection<MyFile> myFilesList = new ObservableCollection<MyFile>(); | |
var filesResults = await _spFilesClient.Files.ExecuteAsync(); | |
var files = filesResults.CurrentPage.OfType<Microsoft.Office365.SharePoint.File>().ToList(); | |
foreach (var file in files) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<ObservableCollection<MyFile>> GetMyFiles(string strFolderName) | |
{ | |
//MyFile is the business object | |
ObservableCollection<MyFile> myFilesList = new ObservableCollection<MyFile>(); | |
//get the files from the folder | |
var filesResults = await _spFilesClient.Files[strFolderName].ToFolder().Children.ExecuteAsync(); | |
//get the results from current page | |
var files = filesResults.CurrentPage.OfType<Microsoft.Office365.SharePoint.File>().ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<Stream> GetFileContent(string strFileId) | |
{ | |
var file = (IFileFetcher)(await _spFilesClient.Files.GetById(strFileId).ToFile().ExecuteAsync()); | |
var streamFileContent = await file.DownloadAsync(); | |
streamFileContent.Seek(0, System.IO.SeekOrigin.Begin); | |
return streamFileContent; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<MyFile> Create(string strFileName, Stream streamFileContent) | |
{ | |
//MyFile is the business object | |
MyFile myFile = null; | |
//add the file to OneDrive | |
//file name will be the full file name along with the extension | |
IFile file = await _spFilesClient.Files.AddAsync(strFileName, true, streamFileContent); | |
if (file != null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task Update(MyFile myFile, Stream streamFileContent) | |
{ | |
var file = await _spFilesClient.Files.GetById(myFile.Id).ToFile().ExecuteAsync(); | |
file.Name = myFile.Name; | |
await file.UpdateAsync(); | |
} |
OlderNewer