Created
June 25, 2021 01:37
-
-
Save MahdiKarimipour/6ac22766dcb1ed0af29d6e500821f273 to your computer and use it in GitHub Desktop.
Unit of Work Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomerService : ICustomerService | |
{ | |
private readonly SampleApiDb database; | |
public CustomerService(SampleApiDb database) | |
{ | |
this.database = database; | |
} | |
public async Task<string> CreateStripeCustomer( | |
CreateCustomerRequestViewModel request) | |
{ | |
database.CustomerRepository.Create(new Our.Customer() | |
{ | |
UserId = Guid.Parse("GUID") | |
}); | |
database.CustomerRepository.Get(c => c.UserId == Guid.Parse("GUID")); | |
database.CustomerRepository.Update(Guid.Parse("GUID"), existingCustomer); | |
database.CustomerRepository.Delete(Guid.Parse("GUID")); | |
await database.SaveAsync(); | |
database.CustomerRepository.Query( | |
"Select * from Customers where Id=@customerId", | |
reader => reader.MapToSingle<Customer>(), | |
new[] { new SqlParameter("customerId", "GUID") }); | |
database.CustomerRepository.Procedure<Customer>( | |
"dbo.GetCustomer", | |
new[] { new SqlParameter("customerId", Guid.Parse("GUID")) }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment