Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
payments
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Юнусов Ибрагим
payments
Commits
9662b37a
Commit
9662b37a
authored
Jul 06, 2022
by
Юнусов Ибрагим
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил паттерн репозиторий
parent
95309e32
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
141 additions
and
0 deletions
+141
-0
PaymentDbContext.cs
...ment.WebApi/Infrastructures/Databases/PaymentDbContext.cs
+23
-0
Supplier.cs
Payments/Payment.WebApi/Models/DbModels/Supplier.cs
+7
-0
User.cs
Payments/Payment.WebApi/Models/DbModels/User.cs
+16
-0
UserBalance.cs
Payments/Payment.WebApi/Models/DbModels/UserBalance.cs
+10
-0
IRepository.cs
...nts/Payment.WebApi/Repositories/Interfaces/IRepository.cs
+9
-0
ISupplierRepository.cs
...ent.WebApi/Repositories/Interfaces/ISupplierRepository.cs
+8
-0
IUserRepository.cs
...Payment.WebApi/Repositories/Interfaces/IUserRepository.cs
+8
-0
SupplierRepository.cs
Payments/Payment.WebApi/Repositories/SupplierRepository.cs
+41
-0
UserRepository.cs
Payments/Payment.WebApi/Repositories/UserRepository.cs
+19
-0
No files found.
Payments/Payment.WebApi/Infrastructures/Databases/PaymentDbContext.cs
0 → 100644
View file @
9662b37a
using
Microsoft.EntityFrameworkCore
;
using
Payment.WebApi.Models.DbModels
;
namespace
Payment.WebApi.Infrastructures.Databases
;
public
class
PaymentDbContext
:
DbContext
{
public
DbSet
<
User
>
Users
{
get
;
set
;
}
public
DbSet
<
Supplier
>
Suppliers
{
get
;
set
;
}
public
PaymentDbContext
(
DbContextOptions
<
PaymentDbContext
>
options
)
:
base
(
options
)
{
}
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
base
.
OnModelCreating
(
modelBuilder
);
modelBuilder
.
SeedUser
();
modelBuilder
.
SeedSupplier
();
modelBuilder
.
SeedUserBalance
();
}
}
\ No newline at end of file
Payments/Payment.WebApi/Models/DbModels/Supplier.cs
0 → 100644
View file @
9662b37a
namespace
Payment.WebApi.Models.DbModels
;
public
class
Supplier
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
}
\ No newline at end of file
Payments/Payment.WebApi/Models/DbModels/User.cs
0 → 100644
View file @
9662b37a
namespace
Payment.WebApi.Models.DbModels
;
public
class
User
{
public
int
Id
{
get
;
set
;
}
public
string
FirstName
{
get
;
set
;
}
public
string
LastName
{
get
;
set
;
}
public
string
?
MiddleName
{
get
;
set
;
}
public
int
Age
{
get
;
set
;
}
public
List
<
UserBalance
>
Balances
{
get
;
set
;
}
public
User
()
{
Balances
=
new
List
<
UserBalance
>();
}
}
\ No newline at end of file
Payments/Payment.WebApi/Models/DbModels/UserBalance.cs
0 → 100644
View file @
9662b37a
namespace
Payment.WebApi.Models.DbModels
;
public
class
UserBalance
{
public
int
Id
{
get
;
set
;
}
public
decimal
Amount
{
get
;
set
;
}
public
string
Currency
{
get
;
set
;
}
public
int
UserId
{
get
;
set
;
}
public
User
User
{
get
;
set
;
}
}
\ No newline at end of file
Payments/Payment.WebApi/Repositories/Interfaces/IRepository.cs
0 → 100644
View file @
9662b37a
namespace
Payment.WebApi.Repositories.Interfaces
;
public
interface
IRepository
<
T
>
{
void
Create
(
T
item
);
void
Update
(
T
item
);
void
Remove
(
T
item
);
void
Save
();
}
\ No newline at end of file
Payments/Payment.WebApi/Repositories/Interfaces/ISupplierRepository.cs
0 → 100644
View file @
9662b37a
using
Payment.WebApi.Models.DbModels
;
namespace
Payment.WebApi.Repositories.Interfaces
;
public
interface
ISupplierRepository
:
IRepository
<
Supplier
>
{
List
<
Supplier
>
GetAll
();
}
\ No newline at end of file
Payments/Payment.WebApi/Repositories/Interfaces/IUserRepository.cs
0 → 100644
View file @
9662b37a
using
Payment.WebApi.Models.DbModels
;
namespace
Payment.WebApi.Repositories.Interfaces
;
public
interface
IUserRepository
:
IRepository
<
User
>
{
User
?
GetFirstOrDefaultById
(
int
id
);
}
\ No newline at end of file
Payments/Payment.WebApi/Repositories/SupplierRepository.cs
0 → 100644
View file @
9662b37a
using
Payment.WebApi.Infrastructures.Databases
;
using
Payment.WebApi.Models.DbModels
;
using
Payment.WebApi.Repositories.Interfaces
;
namespace
Payment.WebApi.Repositories
;
public
class
SupplierRepository
:
ISupplierRepository
{
private
readonly
PaymentDbContext
_context
;
public
SupplierRepository
(
PaymentDbContext
context
)
{
_context
=
context
??
throw
new
ArgumentNullException
(
nameof
(
context
));
}
public
List
<
Supplier
>
GetAll
()
{
var
suppliers
=
_context
.
Suppliers
.
ToList
();
return
suppliers
;
}
public
void
Create
(
Supplier
item
)
{
_context
.
Suppliers
.
Add
(
item
);
}
public
void
Update
(
Supplier
item
)
{
_context
.
Suppliers
.
Update
(
item
);
}
public
void
Remove
(
Supplier
item
)
{
_context
.
Suppliers
.
Remove
(
item
);
}
public
void
Save
()
{
_context
.
SaveChanges
();
}
}
\ No newline at end of file
Payments/Payment.WebApi/Repositories/UserRepository.cs
0 → 100644
View file @
9662b37a
using
Payment.WebApi.Infrastructures.Databases
;
using
Payment.WebApi.Models.DbModels
;
using
Payment.WebApi.Repositories.Interfaces
;
namespace
Payment.WebApi.Repositories
;
public
class
UserRepository
:
IUserRepository
{
private
readonly
PaymentDbContext
_context
;
public
UserRepository
(
PaymentDbContext
context
)
=>
_context
=
context
??
throw
new
ArgumentNullException
(
nameof
(
context
));
public
User
?
GetFirstOrDefaultById
(
int
id
)
=>
_context
.
Users
.
FirstOrDefault
(
s
=>
s
.
Id
==
id
);
public
void
Create
(
User
item
)
=>
_context
.
Users
.
Add
(
item
);
public
void
Update
(
User
item
)
=>
_context
.
Users
.
Update
(
item
);
public
void
Remove
(
User
item
)
=>
_context
.
Users
.
Remove
(
item
);
public
void
Save
()
=>
_context
.
SaveChanges
();
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment