public async Task <CustomerDto> getCustomer(string id) { _logger.LogInformation("Inside getCustomer(string id)"); CoreDBCustomer dbCustomer = await _cosmosDB.GetCustomerAsync(id); CustomerDto dto = new CustomerDto { Id = Guid.Parse(dbCustomer.Id), FirstName = dbCustomer.FirstName, LastName = dbCustomer.LastName, Address = new AddressDto { Line1 = dbCustomer.Address.Line1, Line2 = dbCustomer.Address.Line2, City = dbCustomer.Address.City, State = dbCustomer.Address.State, Zip = dbCustomer.Address.Zip, } }; _logger.LogInformation("Leaving getCustomer(string id)", dto); return(dto); }
public async Task <CustomerDto> updateCustomer(CustomerDto customerDTO) { _logger.LogInformation("Inside updateCustomer(CustomerDto customerDTO)"); CoreDBCustomer dBCustomer = new CoreDBCustomer { Id = customerDTO.Id.ToString(), FirstName = customerDTO.FirstName, LastName = customerDTO.LastName, Address = new Address { Line1 = customerDTO.Address.Line1, Line2 = customerDTO.Address.Line2, City = customerDTO.Address.City, State = customerDTO.Address.State, Zip = customerDTO.Address.Zip, } }; _logger.LogInformation(dBCustomer.Id); CoreDBCustomer result = await _cosmosDB.UpdateCustomerAsync(dBCustomer.Id, dBCustomer); CustomerDto dto = new CustomerDto { Id = Guid.Parse(result.Id), FirstName = result.FirstName, LastName = result.LastName, Address = new AddressDto { Line1 = result.Address.Line1, Line2 = result.Address.Line2, City = result.Address.City, State = result.Address.State, Zip = result.Address.Zip } }; _logger.LogInformation("Leaving updateCustomer(CustomerDto customerDTO)", dto); return(dto); }
public async Task <CoreDBCustomer> UpdateCustomerAsync(string id, CoreDBCustomer dBCustomer) { ItemResponse <CoreDBCustomer> response = await this._container.UpsertItemAsync <CoreDBCustomer>(dBCustomer, new PartitionKey(id)); return(response); }
public async Task <CoreDBCustomer> AddCustomerAsync(CoreDBCustomer dBCustomer) { ItemResponse <CoreDBCustomer> response = await this._container.CreateItemAsync <CoreDBCustomer>(dBCustomer, new PartitionKey(dBCustomer.Id)); return(response); }