예제 #1
0
        //https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/how-to-convert-a-string-to-a-number

        public static CosmosDog ConvertToCosmosDog(Dog dog)
        {
            var myIdString  = (dog.Id).ToString();
            var myCosmosDog = new CosmosDog()
            {
                Id               = myIdString,
                Name             = dog.Name,
                FurColor         = dog.FurColor,
                DogPictureURL    = dog.DogPictureURL,
                DogPictureFile   = dog.DogPictureFile,
                DogPictureSource = dog.DogPictureSource
            };

            return(myCosmosDog);
        }
예제 #2
0
        public static Dog ConvertToDog(CosmosDog cosmosDog)
        {
            var myIdInt = Int32.Parse(cosmosDog.Id);

            var myDog = new Dog()
            {
                Id               = myIdInt,
                Name             = cosmosDog.Name,
                FurColor         = cosmosDog.FurColor,
                DogPictureURL    = cosmosDog.DogPictureURL,
                DogPictureFile   = cosmosDog.DogPictureFile,
                DogPictureSource = cosmosDog.DogPictureSource
            };

            return(myDog);
        }
예제 #3
0
 //PUT
 public static async Task PutCosmosDogAsync(CosmosDog cosmosDog2)
 {
     await myDocumentClient.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, cosmosDog2.Id), cosmosDog2);
 }
예제 #4
0
 //DELETE
 public static async Task DeleteCosmosDogAsync(CosmosDog deleteCosmosDog)
 {
     await myDocumentClient.DeleteDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, deleteCosmosDog.Id));
 }
예제 #5
0
 //POST
 public static async Task PostCosmosDogAsync(CosmosDog cosmosDog)
 {
     await myDocumentClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId), cosmosDog);
 }