Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
ProjectsStatusManagement
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
hasan.bahjat
ProjectsStatusManagement
Commits
157eceaa
Commit
157eceaa
authored
Aug 11, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some updates
parent
da9d0201
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
2161 additions
and
16 deletions
+2161
-16
AppDbContext.cs
...Infrastructure.Persistence/AppDataContext/AppDbContext.cs
+1
-1
DependencyInjection.cs
...ment.Infrastructure.Persistence/DI/DependencyInjection.cs
+6
-1
CustomerEntityConfiguration.cs
...ence/EntitiesConfiguration/CustomerEntityConfiguration.cs
+1
-1
EmployeeEntityConfiguration.cs
...ence/EntitiesConfiguration/EmployeeEntityConfiguration.cs
+14
-1
20240811101043_SeedData.Designer.cs
...ersistence/Migrations/20240811101043_SeedData.Designer.cs
+934
-0
20240811101043_SeedData.cs
...ructure.Persistence/Migrations/20240811101043_SeedData.cs
+17
-0
20240811110031_SeedData1.Designer.cs
...rsistence/Migrations/20240811110031_SeedData1.Designer.cs
+967
-0
20240811110031_SeedData1.cs
...ucture.Persistence/Migrations/20240811110031_SeedData1.cs
+117
-0
AppDbContextModelSnapshot.cs
...cture.Persistence/Migrations/AppDbContextModelSnapshot.cs
+42
-9
CustomersReposiotry.cs
...ce/Repositories/CustomerRepository/CustomersReposiotry.cs
+1
-1
EmployeesRespository.cs
...e/Repositories/EmployeeRepository/EmployeesRespository.cs
+13
-0
ProjectsRepository.cs
...ence/Repositories/ProjectRepository/ProjectsRepository.cs
+8
-2
UsersRepository.cs
...ersistence/Repositories/UserRepository/UsersRepository.cs
+14
-0
SeedData.cs
...nt.Infrastructure.Persistence/SeedDataContext/SeedData.cs
+26
-0
No files found.
PSManagement.Infrastructure.Persistence/AppDataContext/AppDbContext.cs
View file @
157eceaa
using
Microsoft.EntityFrameworkCore
;
using
PSManagement.Domain.Customers.
Aggregate
;
using
PSManagement.Domain.Customers.
Entities
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Identity.Entities
;
using
PSManagement.Domain.Projects.Entities
;
...
...
PSManagement.Infrastructure.Persistence/DI/DependencyInjection.cs
View file @
157eceaa
...
...
@@ -2,9 +2,12 @@
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
PSManagement.Domain.Customers.Repositories
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.Domain.Identity.Repositories
;
using
PSManagement.Domain.Projects.Builders
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.Infrastructure.Persistence.Repositories.CustomerRepository
;
using
PSManagement.Infrastructure.Persistence.Repositories.EmployeeRepository
;
using
PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
;
using
PSManagement.Infrastructure.Persistence.Repositories.UserRepository
;
using
PSManagement.Infrastructure.Persistence.UoW
;
...
...
@@ -23,9 +26,11 @@ namespace PSManagement.Infrastructure.Persistence.DI
services
.
AddScoped
<
IUsersRepository
,
UsersRepository
>();
services
.
AddScoped
<
ICustomersRepository
,
CustomersReposiotry
>();
services
.
AddScoped
<
IProjectsRepository
,
ProjectsRepository
>();
services
.
AddScoped
<
IRolesRepository
,
RolesRepository
>();
services
.
AddScoped
<
IEmployeesRepository
,
EmployeesRespository
>();
services
.
AddScoped
<
ProjectBuilder
>();
services
.
AddScoped
<
IUnitOfWork
,
UnitOfWork
>();
return
services
;
}
...
...
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/CustomerEntityConfiguration.cs
View file @
157eceaa
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
PSManagement.Domain.Customers.
Aggregate
;
using
PSManagement.Domain.Customers.
Entities
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/EmployeeEntityConfiguration.cs
View file @
157eceaa
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Identity.Entities
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
namespace
PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public
class
EmployeeEntityConfiguration
:
IEntityTypeConfiguration
<
Employee
>
public
class
EmployeeEntityConfiguration
:
IEntityTypeConfiguration
<
Employee
>
,
IEntityTypeConfiguration
<
User
>
{
public
void
Configure
(
EntityTypeBuilder
<
Employee
>
builder
)
{
...
...
@@ -41,5 +42,17 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
}
public
void
Configure
(
EntityTypeBuilder
<
User
>
builder
)
{
builder
.
HasMany
(
u
=>
u
.
Roles
)
.
WithMany
(
r
=>
r
.
Users
)
.
UsingEntity
<
Dictionary
<
string
,
object
>>(
"UserRole"
,
j
=>
j
.
HasOne
<
Role
>().
WithMany
().
HasForeignKey
(
"RoleId"
),
j
=>
j
.
HasOne
<
User
>().
WithMany
().
HasForeignKey
(
"UserId"
)
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240811101043_SeedData.Designer.cs
0 → 100644
View file @
157eceaa
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240811101043_SeedData.cs
0 → 100644
View file @
157eceaa
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
SeedData
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240811110031_SeedData1.Designer.cs
0 → 100644
View file @
157eceaa
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240811110031_SeedData1.cs
0 → 100644
View file @
157eceaa
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
SeedData1
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"RoleUser"
);
migrationBuilder
.
CreateTable
(
name
:
"UserRole"
,
columns
:
table
=>
new
{
RoleId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
UserId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_UserRole"
,
x
=>
new
{
x
.
RoleId
,
x
.
UserId
});
table
.
ForeignKey
(
name
:
"FK_UserRole_Roles_RoleId"
,
column
:
x
=>
x
.
RoleId
,
principalTable
:
"Roles"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
table
.
ForeignKey
(
name
:
"FK_UserRole_Users_UserId"
,
column
:
x
=>
x
.
UserId
,
principalTable
:
"Users"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
});
migrationBuilder
.
InsertData
(
table
:
"Roles"
,
columns
:
new
[]
{
"Id"
,
"Name"
},
values
:
new
object
[,]
{
{
1
,
"Admin"
},
{
2
,
"Employee"
},
{
3
,
"Scientific-Supervisor"
}
});
migrationBuilder
.
InsertData
(
table
:
"Users"
,
columns
:
new
[]
{
"Id"
,
"Email"
,
"HashedPassword"
,
"UserName"
},
values
:
new
object
[]
{
1210
,
"Admin@Admin"
,
"1234"
,
"Admin"
});
migrationBuilder
.
InsertData
(
table
:
"UserRole"
,
columns
:
new
[]
{
"RoleId"
,
"UserId"
},
values
:
new
object
[]
{
1
,
1210
});
migrationBuilder
.
CreateIndex
(
name
:
"IX_UserRole_UserId"
,
table
:
"UserRole"
,
column
:
"UserId"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"UserRole"
);
migrationBuilder
.
DeleteData
(
table
:
"Roles"
,
keyColumn
:
"Id"
,
keyValue
:
2
);
migrationBuilder
.
DeleteData
(
table
:
"Roles"
,
keyColumn
:
"Id"
,
keyValue
:
3
);
migrationBuilder
.
DeleteData
(
table
:
"Users"
,
keyColumn
:
"Id"
,
keyValue
:
2
);
migrationBuilder
.
DeleteData
(
table
:
"Roles"
,
keyColumn
:
"Id"
,
keyValue
:
1
);
migrationBuilder
.
CreateTable
(
name
:
"RoleUser"
,
columns
:
table
=>
new
{
RolesId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
UsersId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_RoleUser"
,
x
=>
new
{
x
.
RolesId
,
x
.
UsersId
});
table
.
ForeignKey
(
name
:
"FK_RoleUser_Roles_RolesId"
,
column
:
x
=>
x
.
RolesId
,
principalTable
:
"Roles"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
table
.
ForeignKey
(
name
:
"FK_RoleUser_Users_UsersId"
,
column
:
x
=>
x
.
UsersId
,
principalTable
:
"Users"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
});
migrationBuilder
.
CreateIndex
(
name
:
"IX_RoleUser_UsersId"
,
table
:
"RoleUser"
,
column
:
"UsersId"
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs
View file @
157eceaa
...
...
@@ -119,6 +119,23 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Roles"
);
b
.
HasData
(
new
{
Id
=
1
,
Name
=
"Admin"
},
new
{
Id
=
2
,
Name
=
"Employee"
},
new
{
Id
=
3
,
Name
=
"Scientific-Supervisor"
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Identity.Entities.User"
,
b
=>
...
...
@@ -140,6 +157,15 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Users"
);
b
.
HasData
(
new
{
Id
=
2
,
Email
=
"Admin@Admin"
,
HashedPassword
=
"1234"
,
UserName
=
"Admin"
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.Attachment"
,
b
=>
...
...
@@ -417,19 +443,26 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
ToTable
(
"PermissionRole"
);
});
modelBuilder
.
Entity
(
"
RoleUser
"
,
b
=>
modelBuilder
.
Entity
(
"
UserRole
"
,
b
=>
{
b
.
Property
<
int
>(
"Role
s
Id"
)
b
.
Property
<
int
>(
"RoleId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"User
s
Id"
)
b
.
Property
<
int
>(
"UserId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"RolesId"
,
"UsersId"
);
b
.
HasKey
(
"RoleId"
,
"UserId"
);
b
.
HasIndex
(
"UserId"
);
b
.
HasIndex
(
"UsersId
"
);
b
.
ToTable
(
"UserRole
"
);
b
.
ToTable
(
"RoleUser"
);
b
.
HasData
(
new
{
RoleId
=
1
,
UserId
=
1
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Aggregate.Customer"
,
b
=>
...
...
@@ -870,17 +903,17 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.
IsRequired
();
});
modelBuilder
.
Entity
(
"
RoleUser
"
,
b
=>
modelBuilder
.
Entity
(
"
UserRole
"
,
b
=>
{
b
.
HasOne
(
"PSManagement.Domain.Identity.Entities.Role"
,
null
)
.
WithMany
()
.
HasForeignKey
(
"Role
s
Id"
)
.
HasForeignKey
(
"RoleId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
b
.
HasOne
(
"PSManagement.Domain.Identity.Entities.User"
,
null
)
.
WithMany
()
.
HasForeignKey
(
"User
s
Id"
)
.
HasForeignKey
(
"UserId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
});
...
...
PSManagement.Infrastructure.Persistence/Repositories/CustomerRepository/CustomersReposiotry.cs
View file @
157eceaa
using
PSManagement.Domain.Customers.
Aggregate
;
using
PSManagement.Domain.Customers.
Entities
;
using
PSManagement.Domain.Customers.Repositories
;
using
PSManagement.Infrastructure.Persistence.Repositories.Base
;
using
System
;
...
...
PSManagement.Infrastructure.Persistence/Repositories/EmployeeRepository/EmployeesRespository.cs
0 → 100644
View file @
157eceaa
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Repositories
;
using
PSManagement.Infrastructure.Persistence.Repositories.Base
;
namespace
PSManagement.Infrastructure.Persistence.Repositories.EmployeeRepository
{
public
class
EmployeesRespository
:
BaseRepository
<
Employee
>,
IEmployeesRepository
{
public
EmployeesRespository
(
AppDbContext
context
)
:
base
(
context
)
{
}
}
}
PSManagement.Infrastructure.Persistence/Repositories/ProjectRepository/ProjectsRepository.cs
View file @
157eceaa
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.Infrastructure.Persistence.Repositories.Base
;
using
PSManagement.SharedKernel.Repositories
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -7,7 +10,10 @@ using System.Threading.Tasks;
namespace
PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
{
public
class
ProjectsRepository
:
IProjectsRepository
public
class
ProjectsRepository
:
BaseRepository
<
Project
>
,
IProjectsRepository
{
public
ProjectsRepository
(
AppDbContext
context
)
:
base
(
context
)
{
}
}
}
PSManagement.Infrastructure.Persistence/Repositories/UserRepository/UsersRepository.cs
View file @
157eceaa
...
...
@@ -29,4 +29,18 @@ namespace PSManagement.Infrastructure.Persistence.Repositories.UserRepository
}
public
class
RolesRepository
:
BaseRepository
<
Role
>,
IRolesRepository
{
public
RolesRepository
(
AppDbContext
context
)
:
base
(
context
)
{
}
public
async
Task
<
Role
>
GetByRoleName
(
string
roleName
,
ISpecification
<
Role
>
specification
=
null
)
{
IEnumerable
<
Role
>
roles
=
await
this
.
ListAsync
(
specification
);
return
roles
.
FirstOrDefault
(
r
=>
r
.
Name
==
roleName
);
}
}
}
PSManagement.Infrastructure.Persistence/SeedDataContext/SeedData.cs
View file @
157eceaa
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Logging
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Identity.Entities
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -14,6 +15,8 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
public
static
Task
SeedAsync
(
ModelBuilder
builder
)
{
SeedDepartments
(
builder
);
SeedAdmin
(
builder
);
SeedRoles
(
builder
);
return
Task
.
CompletedTask
;
}
public
static
void
SeedDepartments
(
ModelBuilder
builder
)
{
...
...
@@ -27,6 +30,29 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
)
;
}
public
static
void
SeedRoles
(
ModelBuilder
builder
)
{
builder
.
Entity
<
Role
>().
HasData
(
new
Role
{
Id
=
1
,
Name
=
"Admin"
},
new
Role
{
Id
=
2
,
Name
=
"Employee"
},
new
Role
{
Id
=
3
,
Name
=
"Scientific-Supervisor"
}
);
}
public
static
void
SeedAdmin
(
ModelBuilder
builder
)
{
builder
.
Entity
<
User
>().
HasData
(
new
User
{
Id
=
2
,
UserName
=
"Admin"
,
Email
=
"Admin@Admin"
,
HashedPassword
=
"1234"
}
);
builder
.
Entity
(
"UserRole"
).
HasData
(
new
Dictionary
<
string
,
object
>
{
[
"UserId"
]
=
1
,
[
"RoleId"
]
=
1
}
);
}
}
}
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