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 async Task<List<string>> GetDocumentAttachment(string attachmentUrl) | |
{ | |
var attachmentLinks = new List<string>(); | |
try | |
{ | |
var attachments = await _client.ReadAttachmentFeedAsync(attachmentUrl); | |
foreach (var attachment in attachments) attachmentLinks.Add(attachment.MediaLink); | |
} | |
catch (Exception ex) | |
{ |
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 async Task<List<string>> GetDocumentAttachment(string attachmentUrl) | |
{ | |
var attachmentLinks = new List<string>(); | |
try | |
{ | |
var attachments = await _client.ReadAttachmentFeedAsync(attachmentUrl); | |
foreach (var attachment in attachments) attachmentLinks.Add(attachment.MediaLink); | |
} | |
catch (Exception ex) | |
{ |
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 async Task<Document> UpdateDocumentAsync(string id, T item, List<BlobDetails> lstBlobDetails) | |
{ | |
try | |
{ | |
var updateResponse = | |
await _client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(_databaseId, _collectionId, id), | |
item); | |
if (updateResponse.StatusCode != HttpStatusCode.OK) return updateResponse; | |
var attachmentsUrl = string.Concat(updateResponse.Resource.AltLink, "/attachments/"); |
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 async Task<Document> CreateDocumentAsync(T item, List<BlobDetails> lstBlobDetailses) | |
{ | |
try | |
{ | |
var response = | |
await _client.CreateDocumentAsync( | |
UriFactory.CreateDocumentCollectionUri(_databaseId, _collectionId), item); | |
if (response.StatusCode != HttpStatusCode.Created) return response; | |
var attachmentUrl = string.Concat(response.Resource.AltLink, "/attachments/"); //AltLink, will give us the encoded url for the document in cosmosdb |
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
{ | |
"resortName":"", | |
"resortDescription":"", | |
"resortLocation":"", | |
"thingsToDo":"", | |
"documents":"", /* object which holds all types of documents, media/blobs */ | |
"resortType":"", | |
"resortAddress":{ | |
"streetAddress":"", | |
"city":"", |
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
Usage of Dynamic | |
----------------- | |
I have used Dynamic instead of object. If I use object then I have to write typecasting statements when reading the integer values in the array. | |
Readability is good with dynamic. | |
Usage of Queue | |
--------------- | |
Since we are reading the elements in the FIFO order, I used Queue rather than List. |
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
<system.serviceModel> | |
<client> | |
<endpoint name="YourService" contract="<namespace.IYourService>" binding="netTcpRelayBinding" address="sb://<relaynamespace>.servicebus.windows.net/<serviceAddress>" behaviorConfiguration="sbTokenProvider"></endpoint> | |
</client> | |
<behaviors> | |
<endpointBehaviors> | |
<behavior name="sbTokenProvider"> | |
<transportClientEndpointBehavior> | |
<tokenProvider> | |
<sharedAccessSignature keyName="RootManageSharedAccessKey" key="<SAS key>" /> |
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 interface IServiceChannel : IYourService, IClientChannel | |
{ | |
} |
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
static void Main(string[] args) | |
{ | |
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect; | |
var serviceChannelObj = new ChannelFactory<Iservicechannel>("yourService"); | |
var response = new YourObject(); | |
Iservicechannel channel = null; | |
try | |
{ | |
channel = serviceChannelObj.CreateChannel(); | |
response = channel.GetDetails(someValue); |
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 class YourService : IYourService | |
{ | |
public YourObject GetDetails(int id) | |
{ | |
Console.WriteLine($"Requested Id {id}"); | |
return new YourObject | |
{ | |
//Data | |
}; | |
} |
NewerOlder