Пример #1
0
    private static async Task Main(string[] args)
    {
        var myCosmosService = new CosmosService();
        await myCosmosService.InitializeAsync(endpointUrl, accountKey);

        var newContact1 = new Contact
        {
            Id        = Guid.NewGuid().ToString(),
            FirstName = "mithun",
            LastName  = "shanbhag",
            Email     = "*****@*****.**",
            City      = "Bangalore"
        };

        var newContact2 = new Contact
        {
            Id        = Guid.NewGuid().ToString(),
            FirstName = "john",
            LastName  = "doe",
            Email     = "*****@*****.**",
            City      = "Delhi"
        };

        try
        {
            await myCosmosService.AddContactAsync(newContact1);

            await myCosmosService.AddContactAsync(newContact2);

            foreach (var contact in await myCosmosService.ListContactsAsync())
            {
            }

            var contactToModify = await myCosmosService.GetContactAsync(newContact2.Id);

            contactToModify.FirstName = "Jane";
            await myCosmosService.UpdateContactAsync(contactToModify.Id, contactToModify);
        }
        finally
        {
            //await myCosmosService.DeleteContactAsync(newContact1.Id);
            //await myCosmosService.DeleteContactAsync(newContact1.Id);
        }
    }