コード例 #1
0
ファイル: OrderRepository.cs プロジェクト: TimothyK/Retail
 public double GetCustomerDiscount(ICustomerIdentifier customer)
 {
     return(CreateDbContext().Customers.AsNoTracking()
            .SingleOrDefault(cust => cust.CustomerId == customer.CustomerId)
            ?.Discount
            ?? throw new CustomerNotFoundException(customer));
 }
コード例 #2
0
 private void SetupCustomerDiscount(ICustomerIdentifier customer, double discount)
 {
     _repo
     .Setup(repo => repo.GetCustomerDiscount(customer))
     .Returns(discount);
 }
コード例 #3
0
 public CustomerNotFoundException(ICustomerIdentifier customer) : base($"Customer {customer.CustomerId} was not found")
 {
     Customer = customer;
 }