public async Task Upsert_ShouldCallRepository()
        {
            var upsertCustomer = new UpsertCustomer();

            _mockRepository.Stub(r => r.UpsertCustomerAsync(upsertCustomer))
            .ReturnAsync(true);

            await _sut.UpsertAsync(upsertCustomer);

            _mockRepository.AssertWasCalled(r => r.UpsertCustomerAsync(upsertCustomer), r => r.Repeat.Once());
        }
        public async Task <bool> UpsertCustomerAsync(UpsertCustomer customer)
        {
            using (var connection = _sqlConnection.GetConnection())
            {
                var parameters = new
                {
                    Id = customer.Id ?? -1,
                    customer.Name,
                    customer.PreviouslyOrdered,
                    customer.WebCustomer,
                    customer.LastActive,
                    Colours = customer.FavouriteColours.StringToDataTable()
                };

                var affectedRows = await connection.ExecuteAsync("dbo.Customer_Upsert", parameters,
                                                                 commandType : CommandType.StoredProcedure, commandTimeout : 0)
                                   .ConfigureAwait(false);

                return(affectedRows != 0);
            }
        }
Exemplo n.º 3
0
        public async Task <bool> UpsertCustomerAsync(UpsertCustomer customer)
        {
            var response = await _httpClient.PostAsJsonAsync("customer", customer).ConfigureAwait(false);

            return(response.IsSuccessStatusCode);
        }
 public async Task <IHttpActionResult> UpsertAsync(UpsertCustomer customer)
 {
     return(Ok(await _repository.UpsertCustomerAsync(customer).ConfigureAwait(false)));
 }