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
0f8a3073
Commit
0f8a3073
authored
Aug 26, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix s
parent
a946c6cb
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
2816 additions
and
37 deletions
+2816
-37
AppDbContext.cs
...Infrastructure.Persistence/AppDataContext/AppDbContext.cs
+2
-2
DependencyInjection.cs
...e/DependencyInjectionConfiguration/DependencyInjection.cs
+47
-7
ProjectEntityConfiguration.cs
...tence/EntitiesConfiguration/ProjectEntityConfiguration.cs
+15
-0
20240826084243_AddProjectTypeDetails.Designer.cs
...grations/20240826084243_AddProjectTypeDetails.Designer.cs
+1204
-0
20240826084243_AddProjectTypeDetails.cs
...stence/Migrations/20240826084243_AddProjectTypeDetails.cs
+44
-0
20240826085542_AddParticipationHistory.Designer.cs
...ations/20240826085542_AddParticipationHistory.Designer.cs
+1262
-0
20240826085542_AddParticipationHistory.cs
...ence/Migrations/20240826085542_AddParticipationHistory.cs
+60
-0
AppDbContextModelSnapshot.cs
...cture.Persistence/Migrations/AppDbContextModelSnapshot.cs
+90
-21
ProjectsTypesRepository.cs
...Repositories/ProjectRepository/ProjectsTypesRepository.cs
+1
-1
SeedData.cs
...nt.Infrastructure.Persistence/SeedDataContext/SeedData.cs
+13
-1
UnitOfWork.cs
PSManagement.Infrastructure.Persistence/UoW/UnitOfWork.cs
+35
-2
AuthenticationService.cs
...nt.Infrastructure/Authentication/AuthenticationService.cs
+26
-2
DependencyInjection.cs
...e/DependencyInjectionConfiguration/DependencyInjection.cs
+12
-1
EmployeesSyncJobSettings.cs
...ement.Infrastructure/Settings/EmployeesSyncJobSettings.cs
+1
-0
SyncEmployeesService.cs
PSManagement.Infrastructure/SyncData/SyncEmployeesService.cs
+4
-0
No files found.
PSManagement.Infrastructure.Persistence/AppDataContext/AppDbContext.cs
View file @
0f8a3073
...
@@ -19,6 +19,7 @@ namespace PSManagement.Infrastructure.Persistence
...
@@ -19,6 +19,7 @@ namespace PSManagement.Infrastructure.Persistence
}
}
public
DbSet
<
ParticipationChange
>
ParticipationChanges
{
get
;
set
;
}
public
DbSet
<
User
>
Users
{
get
;
set
;
}
public
DbSet
<
User
>
Users
{
get
;
set
;
}
public
DbSet
<
Role
>
Roles
{
get
;
set
;
}
public
DbSet
<
Role
>
Roles
{
get
;
set
;
}
public
DbSet
<
Permission
>
Permission
{
get
;
set
;
}
public
DbSet
<
Permission
>
Permission
{
get
;
set
;
}
...
@@ -42,8 +43,7 @@ namespace PSManagement.Infrastructure.Persistence
...
@@ -42,8 +43,7 @@ namespace PSManagement.Infrastructure.Persistence
{
{
modelBuilder
.
ApplyConfigurationsFromAssembly
(
typeof
(
AppDbContext
).
Assembly
);
modelBuilder
.
ApplyConfigurationsFromAssembly
(
typeof
(
AppDbContext
).
Assembly
);
// modelBuilder.Entity<BaseEntity>().Ignore(e => e.Events);
SeedData
.
SeedAsync
(
modelBuilder
).
Wait
();
SeedData
.
SeedAsync
(
modelBuilder
).
Wait
();
base
.
OnModelCreating
(
modelBuilder
);
base
.
OnModelCreating
(
modelBuilder
);
...
...
PSManagement.Infrastructure.Persistence/DependencyInjectionConfiguration/DependencyInjection.cs
View file @
0f8a3073
...
@@ -27,10 +27,39 @@ namespace PSManagement.Infrastructure.Persistence.DI
...
@@ -27,10 +27,39 @@ namespace PSManagement.Infrastructure.Persistence.DI
public
static
IServiceCollection
AddPersistence
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
public
static
IServiceCollection
AddPersistence
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
{
services
.
AddDbContext
<
AppDbContext
>(
options
=>
{
services
options
.
UseSqlServer
(
configuration
.
GetConnectionString
(
"DefaultConnection"
));
.
AddBuilders
()
});
.
AddDataContext
(
configuration
)
.
AddRepositories
()
.
AddUOW
();
return
services
;
}
#
region
Register
Builders
private
static
IServiceCollection
AddBuilders
(
this
IServiceCollection
services
)
{
services
.
AddScoped
<
ProjectBuilder
>();
return
services
;
}
#
endregion
Register
Builders
#
region
Register
UOW
private
static
IServiceCollection
AddUOW
(
this
IServiceCollection
services
)
{
services
.
AddScoped
<
IUnitOfWork
,
UnitOfWork
>();
return
services
;
}
#
endregion
Register
UOW
#
region
Register
Repositories
private
static
IServiceCollection
AddRepositories
(
this
IServiceCollection
services
)
{
services
.
AddScoped
(
typeof
(
IRepository
<>),
typeof
(
BaseRepository
<>));
services
.
AddScoped
<
IUsersRepository
,
UsersRepository
>();
services
.
AddScoped
<
IUsersRepository
,
UsersRepository
>();
services
.
AddScoped
<
ICustomersRepository
,
CustomersReposiotry
>();
services
.
AddScoped
<
ICustomersRepository
,
CustomersReposiotry
>();
services
.
AddScoped
<
IProjectsRepository
,
ProjectsRepository
>();
services
.
AddScoped
<
IProjectsRepository
,
ProjectsRepository
>();
...
@@ -41,12 +70,23 @@ namespace PSManagement.Infrastructure.Persistence.DI
...
@@ -41,12 +70,23 @@ namespace PSManagement.Infrastructure.Persistence.DI
services
.
AddScoped
<
ITracksRepository
,
TracksRepository
>();
services
.
AddScoped
<
ITracksRepository
,
TracksRepository
>();
services
.
AddScoped
<
IProjectTypesRepository
,
ProjectsTypesRepository
>();
services
.
AddScoped
<
IProjectTypesRepository
,
ProjectsTypesRepository
>();
services
.
AddScoped
<
ProjectBuilder
>();
services
.
AddScoped
(
typeof
(
IRepository
<>),
typeof
(
BaseRepository
<>));
services
.
AddScoped
<
IUnitOfWork
,
UnitOfWork
>();
return
services
;
return
services
;
}
}
#
endregion
Register
Repositoryies
#
region
Register
Data
context
private
static
IServiceCollection
AddDataContext
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
services
.
AddDbContext
<
AppDbContext
>(
options
=>
{
options
.
UseSqlServer
(
configuration
.
GetConnectionString
(
"DefaultConnection"
));
});
return
services
;
}
#
endregion
Register
Data
Context
}
}
}
}
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/ProjectEntityConfiguration.cs
View file @
0f8a3073
...
@@ -97,6 +97,21 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
...
@@ -97,6 +97,21 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
;
;
}
}
}
public
class
participationChangesConfiguration
:
IEntityTypeConfiguration
<
ParticipationChange
>
{
public
void
Configure
(
EntityTypeBuilder
<
ParticipationChange
>
builder
)
{
builder
.
HasOne
(
e
=>
e
.
Employee
)
.
WithOne
();
builder
.
HasOne
(
e
=>
e
.
Project
)
.
WithOne
()
;
}
}
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240826084243_AddProjectTypeDetails.Designer.cs
0 → 100644
View file @
0f8a3073
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240826084243_AddProjectTypeDetails.cs
0 → 100644
View file @
0f8a3073
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
AddProjectTypeDetails
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AddColumn
<
int
>(
name
:
"StepInfo_NumberOfWorker"
,
table
:
"Steps"
,
type
:
"int"
,
nullable
:
true
);
migrationBuilder
.
AddColumn
<
int
>(
name
:
"ExpectedNumberOfWorker"
,
table
:
"ProjectType"
,
type
:
"int"
,
nullable
:
false
,
defaultValue
:
0
);
migrationBuilder
.
InsertData
(
table
:
"Roles"
,
columns
:
new
[]
{
"Id"
,
"Name"
},
values
:
new
object
[]
{
5
,
"Planner"
});
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DeleteData
(
table
:
"Roles"
,
keyColumn
:
"Id"
,
keyValue
:
5
);
migrationBuilder
.
DropColumn
(
name
:
"StepInfo_NumberOfWorker"
,
table
:
"Steps"
);
migrationBuilder
.
DropColumn
(
name
:
"ExpectedNumberOfWorker"
,
table
:
"ProjectType"
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240826085542_AddParticipationHistory.Designer.cs
0 → 100644
View file @
0f8a3073
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240826085542_AddParticipationHistory.cs
0 → 100644
View file @
0f8a3073
using
System
;
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
AddParticipationHistory
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"ParticipationChanges"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
)
.
Annotation
(
"SqlServer:Identity"
,
"1, 1"
),
EmployeeId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
ProjectId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
PartialTimeBefore
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
PartialTimeAfter
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
RoleBefore
=
table
.
Column
<
string
>(
type
:
"nvarchar(max)"
,
nullable
:
true
),
RoleAfter
=
table
.
Column
<
string
>(
type
:
"nvarchar(max)"
,
nullable
:
true
),
ChangeDate
=
table
.
Column
<
DateTime
>(
type
:
"datetime2"
,
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_ParticipationChanges"
,
x
=>
x
.
Id
);
table
.
ForeignKey
(
name
:
"FK_ParticipationChanges_Employees_EmployeeId"
,
column
:
x
=>
x
.
EmployeeId
,
principalTable
:
"Employees"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
table
.
ForeignKey
(
name
:
"FK_ParticipationChanges_Projects_ProjectId"
,
column
:
x
=>
x
.
ProjectId
,
principalTable
:
"Projects"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
});
migrationBuilder
.
CreateIndex
(
name
:
"IX_ParticipationChanges_EmployeeId"
,
table
:
"ParticipationChanges"
,
column
:
"EmployeeId"
,
unique
:
true
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_ParticipationChanges_ProjectId"
,
table
:
"ParticipationChanges"
,
column
:
"ProjectId"
,
unique
:
true
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"ParticipationChanges"
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs
View file @
0f8a3073
...
@@ -207,6 +207,11 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -207,6 +207,11 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
{
{
Id
=
4
,
Id
=
4
,
Name
=
"Scientific-Deputy"
Name
=
"Scientific-Deputy"
},
new
{
Id
=
5
,
Name
=
"Planner"
});
});
});
});
...
@@ -294,6 +299,45 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -294,6 +299,45 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
ToTable
(
"EmployeeParticipate"
);
b
.
ToTable
(
"EmployeeParticipate"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.ParticipationChange"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b
.
Property
<
DateTime
>(
"ChangeDate"
)
.
HasColumnType
(
"datetime2"
);
b
.
Property
<
int
>(
"EmployeeId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"PartialTimeAfter"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"PartialTimeBefore"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"ProjectId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"RoleAfter"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
string
>(
"RoleBefore"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"EmployeeId"
)
.
IsUnique
();
b
.
HasIndex
(
"ProjectId"
)
.
IsUnique
();
b
.
ToTable
(
"ParticipationChanges"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.Project"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.Project"
,
b
=>
{
{
b
.
Property
<
int
>(
"Id"
)
b
.
Property
<
int
>(
"Id"
)
...
@@ -373,48 +417,51 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -373,48 +417,51 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
ToTable
(
"ProjectCompletion"
);
b
.
ToTable
(
"ProjectCompletion"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.
ProjectType
"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.
Step
"
,
b
=>
{
{
b
.
Property
<
int
>(
"Id"
)
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b
.
Property
<
string
>(
"Description
"
)
b
.
Property
<
int
>(
"CurrentCompletionRatio
"
)
.
HasColumnType
(
"
nvarchar(max)
"
);
.
HasColumnType
(
"
int
"
);
b
.
Property
<
int
>(
"
ExpectedEffort
"
)
b
.
Property
<
int
>(
"
ProjectId
"
)
.
HasColumnType
(
"int"
);
.
HasColumnType
(
"int"
);
b
.
Property
<
string
>(
"TypeName
"
)
b
.
Property
<
int
>(
"Weight
"
)
.
HasColumnType
(
"
nvarchar(max)
"
);
.
HasColumnType
(
"
int
"
);
b
.
HasKey
(
"Id"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"ProjectType"
);
b
.
HasIndex
(
"ProjectId"
);
b
.
ToTable
(
"Steps"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects
.Entities.Step
"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects
Types.Entites.ProjectType
"
,
b
=>
{
{
b
.
Property
<
int
>(
"Id"
)
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b
.
Property
<
int
>(
"CurrentCompletionRatio
"
)
b
.
Property
<
string
>(
"Description
"
)
.
HasColumnType
(
"
int
"
);
.
HasColumnType
(
"
nvarchar(max)
"
);
b
.
Property
<
int
>(
"
ProjectId
"
)
b
.
Property
<
int
>(
"
ExpectedEffort
"
)
.
HasColumnType
(
"int"
);
.
HasColumnType
(
"int"
);
b
.
Property
<
int
>(
"
Weight
"
)
b
.
Property
<
int
>(
"
ExpectedNumberOfWorker
"
)
.
HasColumnType
(
"int"
);
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
Property
<
string
>(
"TypeName"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Has
Index
(
"Project
Id"
);
b
.
Has
Key
(
"
Id"
);
b
.
ToTable
(
"
Steps
"
);
b
.
ToTable
(
"
ProjectType
"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Tracking.EmployeeTrack"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Tracking.EmployeeTrack"
,
b
=>
...
@@ -726,6 +773,25 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -726,6 +773,25 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
Navigation
(
"Project"
);
b
.
Navigation
(
"Project"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.ParticipationChange"
,
b
=>
{
b
.
HasOne
(
"PSManagement.Domain.Employees.Entities.Employee"
,
"Employee"
)
.
WithOne
()
.
HasForeignKey
(
"PSManagement.Domain.Projects.Entities.ParticipationChange"
,
"EmployeeId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
b
.
HasOne
(
"PSManagement.Domain.Projects.Entities.Project"
,
"Project"
)
.
WithOne
()
.
HasForeignKey
(
"PSManagement.Domain.Projects.Entities.ParticipationChange"
,
"ProjectId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
b
.
Navigation
(
"Employee"
);
b
.
Navigation
(
"Project"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.Project"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.Project"
,
b
=>
{
{
b
.
HasOne
(
"PSManagement.Domain.Customers.Entities.Customer"
,
null
)
b
.
HasOne
(
"PSManagement.Domain.Customers.Entities.Customer"
,
null
)
...
@@ -743,13 +809,13 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -743,13 +809,13 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.
HasForeignKey
(
"ProjectManagerId"
)
.
HasForeignKey
(
"ProjectManagerId"
)
.
OnDelete
(
DeleteBehavior
.
Restrict
);
.
OnDelete
(
DeleteBehavior
.
Restrict
);
b
.
HasOne
(
"PSManagement.Domain.Projects
.Entiti
es.ProjectType"
,
"ProjectType"
)
b
.
HasOne
(
"PSManagement.Domain.Projects
Types.Entit
es.ProjectType"
,
"ProjectType"
)
.
WithMany
()
.
WithMany
()
.
HasForeignKey
(
"ProjectTypeId"
)
.
HasForeignKey
(
"ProjectTypeId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
.
IsRequired
();
b
.
HasOne
(
"PSManagement.Domain.Projects
.Entiti
es.ProjectType"
,
null
)
b
.
HasOne
(
"PSManagement.Domain.Projects
Types.Entit
es.ProjectType"
,
null
)
.
WithMany
(
"Projects"
)
.
WithMany
(
"Projects"
)
.
HasForeignKey
(
"ProjectTypeId1"
);
.
HasForeignKey
(
"ProjectTypeId1"
);
...
@@ -946,6 +1012,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -946,6 +1012,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.
HasColumnType
(
"int"
)
.
HasColumnType
(
"int"
)
.
HasColumnName
(
"Duration"
);
.
HasColumnName
(
"Duration"
);
b1
.
Property
<
int
>(
"NumberOfWorker"
)
.
HasColumnType
(
"int"
);
b1
.
Property
<
DateTime
>(
"StartDate"
)
b1
.
Property
<
DateTime
>(
"StartDate"
)
.
HasColumnType
(
"datetime2"
)
.
HasColumnType
(
"datetime2"
)
.
HasColumnName
(
"StartDate"
);
.
HasColumnName
(
"StartDate"
);
...
@@ -1169,14 +1238,14 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -1169,14 +1238,14 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
Navigation
(
"Tracks"
);
b
.
Navigation
(
"Tracks"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.
ProjectType
"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects.Entities.
Step
"
,
b
=>
{
{
b
.
Navigation
(
"
Project
s"
);
b
.
Navigation
(
"
StepTrack
s"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects
.Entities.Step
"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Projects
Types.Entites.ProjectType
"
,
b
=>
{
{
b
.
Navigation
(
"
StepTrack
s"
);
b
.
Navigation
(
"
Project
s"
);
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Tracking.Track"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Tracking.Track"
,
b
=>
...
...
PSManagement.Infrastructure.Persistence/Repositories/ProjectRepository/ProjectsTypesRepository.cs
View file @
0f8a3073
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.Domain.ProjectsTypes.Entites
;
using
PSManagement.Infrastructure.Persistence.Repositories.Base
;
using
PSManagement.Infrastructure.Persistence.Repositories.Base
;
using
PSManagement.SharedKernel.Interfaces
;
using
PSManagement.SharedKernel.Interfaces
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
...
PSManagement.Infrastructure.Persistence/SeedDataContext/SeedData.cs
View file @
0f8a3073
...
@@ -19,6 +19,8 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
...
@@ -19,6 +19,8 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
SeedRoles
(
builder
);
SeedRoles
(
builder
);
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
}
#
region
Configure
Departments
public
static
void
SeedDepartments
(
ModelBuilder
builder
)
{
public
static
void
SeedDepartments
(
ModelBuilder
builder
)
{
builder
.
Entity
<
Department
>().
HasData
(
builder
.
Entity
<
Department
>().
HasData
(
...
@@ -33,17 +35,25 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
...
@@ -33,17 +35,25 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
)
;
)
;
}
}
#
endregion
Configure
Departments
#
region
Seed
Roles
public
static
void
SeedRoles
(
ModelBuilder
builder
)
public
static
void
SeedRoles
(
ModelBuilder
builder
)
{
{
builder
.
Entity
<
Role
>().
HasData
(
builder
.
Entity
<
Role
>().
HasData
(
new
Role
{
Id
=
1
,
Name
=
"Admin"
},
new
Role
{
Id
=
1
,
Name
=
"Admin"
},
new
Role
{
Id
=
2
,
Name
=
"Employee"
},
new
Role
{
Id
=
2
,
Name
=
"Employee"
},
new
Role
{
Id
=
4
,
Name
=
"Scientific-Deputy"
}
new
Role
{
Id
=
4
,
Name
=
"Scientific-Deputy"
},
new
Role
{
Id
=
5
,
Name
=
"Planner"
}
);
);
}
}
#
endregion
Seed
Roles
#
region
Configure
Admin
public
static
void
SeedAdmin
(
ModelBuilder
builder
)
public
static
void
SeedAdmin
(
ModelBuilder
builder
)
{
{
...
@@ -56,5 +66,7 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
...
@@ -56,5 +66,7 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
);
);
}
}
#
endregion
Configure
Admin
}
}
}
}
PSManagement.Infrastructure.Persistence/UoW/UnitOfWork.cs
View file @
0f8a3073
...
@@ -13,54 +13,84 @@ namespace PSManagement.Infrastructure.Persistence.UoW
...
@@ -13,54 +13,84 @@ namespace PSManagement.Infrastructure.Persistence.UoW
{
{
public
class
UnitOfWork
:
IUnitOfWork
public
class
UnitOfWork
:
IUnitOfWork
{
{
#
region
Dependencies
private
readonly
AppDbContext
_dbContext
;
private
readonly
AppDbContext
_dbContext
;
private
readonly
IMediator
_mediator
;
private
readonly
IMediator
_mediator
;
#
endregion
Dependencies
#
region
Constructor
public
UnitOfWork
(
AppDbContext
dbContext
,
IMediator
mediator
)
public
UnitOfWork
(
AppDbContext
dbContext
,
IMediator
mediator
)
{
{
_dbContext
=
dbContext
;
_dbContext
=
dbContext
;
_mediator
=
mediator
;
_mediator
=
mediator
;
}
}
#
endregion
Constructor
public
async
Task
SaveChangesAsync
(
CancellationToken
cancellationToken
=
default
)
public
async
Task
SaveChangesAsync
(
CancellationToken
cancellationToken
=
default
)
{
{
await
DispatchEventsAsync
();
await
DispatchEventsAsync
();
await
_dbContext
.
SaveChangesAsync
(
cancellationToken
);
await
_dbContext
.
SaveChangesAsync
(
cancellationToken
);
}
}
#
region
Process
Events
private
async
Task
DispatchEventsAsync
()
private
async
Task
DispatchEventsAsync
()
{
{
// list for the processed event
var
processedDomainEvents
=
new
List
<
IDomainEvent
>();
var
processedDomainEvents
=
new
List
<
IDomainEvent
>();
// list of un processed events
var
unprocessedDomainEvents
=
GetDomainEvents
().
AsEnumerable
();
var
unprocessedDomainEvents
=
GetDomainEvents
().
AsEnumerable
();
// this is needed incase another DomainEvent is published from a DomainEventHandler
// this is needed incase another DomainEvent is published from a DomainEventHandler
while
(
unprocessedDomainEvents
.
Any
())
while
(
unprocessedDomainEvents
.
Any
())
{
{
// publish domain events
await
DispatchDomainEventsAsync
(
unprocessedDomainEvents
);
await
DispatchDomainEventsAsync
(
unprocessedDomainEvents
);
// move the un processed to the processed
processedDomainEvents
.
AddRange
(
unprocessedDomainEvents
);
processedDomainEvents
.
AddRange
(
unprocessedDomainEvents
);
// get the newest un processed events
unprocessedDomainEvents
=
GetDomainEvents
()
unprocessedDomainEvents
=
GetDomainEvents
()
.
Where
(
e
=>
!
processedDomainEvents
.
Contains
(
e
))
.
Where
(
e
=>
!
processedDomainEvents
.
Contains
(
e
))
.
ToList
();
.
ToList
();
}
}
// clear the events
ClearDomainEvents
();
ClearDomainEvents
();
}
}
#
endregion
Process
Events
#
region
Get
Events
private
List
<
IDomainEvent
>
GetDomainEvents
()
private
List
<
IDomainEvent
>
GetDomainEvents
()
{
{
// change tracker to the base entity
var
aggregateRoots
=
GetTrackedEntites
();
var
aggregateRoots
=
GetTrackedEntites
();
// get the events list
return
aggregateRoots
return
aggregateRoots
.
SelectMany
(
x
=>
x
.
Events
)
.
SelectMany
(
x
=>
x
.
Events
)
.
ToList
();
.
ToList
();
}
}
#
endregion
Get
Events
#
region
Get
Tracked
private
List
<
BaseEntity
>
GetTrackedEntites
()
private
List
<
BaseEntity
>
GetTrackedEntites
()
{
{
// change tracker to the base enties that has an events
return
_dbContext
.
ChangeTracker
return
_dbContext
.
ChangeTracker
.
Entries
<
BaseEntity
>()
.
Entries
<
BaseEntity
>()
.
Where
(
x
=>
x
.
Entity
.
Events
!=
null
&&
x
.
Entity
.
Events
.
Any
())
.
Where
(
x
=>
x
.
Entity
.
Events
!=
null
&&
x
.
Entity
.
Events
.
Any
())
.
Select
(
e
=>
e
.
Entity
)
.
Select
(
e
=>
e
.
Entity
)
.
ToList
();
.
ToList
();
}
}
#
endregion
Get
Tracked
#
region
Dispatch
Events
private
async
Task
DispatchDomainEventsAsync
(
IEnumerable
<
IDomainEvent
>
domainEvents
)
private
async
Task
DispatchDomainEventsAsync
(
IEnumerable
<
IDomainEvent
>
domainEvents
)
{
{
foreach
(
var
domainEvent
in
domainEvents
)
foreach
(
var
domainEvent
in
domainEvents
)
...
@@ -69,6 +99,9 @@ namespace PSManagement.Infrastructure.Persistence.UoW
...
@@ -69,6 +99,9 @@ namespace PSManagement.Infrastructure.Persistence.UoW
}
}
}
}
#
endregion
Dispatch
Events
#
region
Clear
And
Dispose
private
void
ClearDomainEvents
()
private
void
ClearDomainEvents
()
{
{
var
aggregateRoots
=
GetTrackedEntites
();
var
aggregateRoots
=
GetTrackedEntites
();
...
@@ -79,6 +112,6 @@ namespace PSManagement.Infrastructure.Persistence.UoW
...
@@ -79,6 +112,6 @@ namespace PSManagement.Infrastructure.Persistence.UoW
{
{
_dbContext
.
Dispose
();
_dbContext
.
Dispose
();
}
}
#
endregion
Clear
And
Dispose
}
}
}
}
PSManagement.Infrastructure/Authentication/AuthenticationService.cs
View file @
0f8a3073
...
@@ -20,7 +20,11 @@ namespace PSManagement.Infrastructure.Services.Authentication
...
@@ -20,7 +20,11 @@ namespace PSManagement.Infrastructure.Services.Authentication
private
readonly
IUsersRepository
_userRepository
;
private
readonly
IUsersRepository
_userRepository
;
private
readonly
BaseSpecification
<
User
>
_specification
;
private
readonly
BaseSpecification
<
User
>
_specification
;
private
readonly
IMapper
_mapper
;
private
readonly
IMapper
_mapper
;
public
AuthenticationService
(
IJwtTokenGenerator
jwtTokenGenerator
,
IUsersRepository
userRepository
,
IMapper
mapper
)
public
AuthenticationService
(
IJwtTokenGenerator
jwtTokenGenerator
,
IUsersRepository
userRepository
,
IMapper
mapper
)
{
{
_jwtTokenGenerator
=
jwtTokenGenerator
;
_jwtTokenGenerator
=
jwtTokenGenerator
;
_userRepository
=
userRepository
;
_userRepository
=
userRepository
;
...
@@ -28,15 +32,21 @@ namespace PSManagement.Infrastructure.Services.Authentication
...
@@ -28,15 +32,21 @@ namespace PSManagement.Infrastructure.Services.Authentication
_mapper
=
mapper
;
_mapper
=
mapper
;
}
}
#
region
Login
public
async
Task
<
Result
<
AuthenticationResult
>>
Login
(
String
email
,
String
password
)
{
public
async
Task
<
Result
<
AuthenticationResult
>>
Login
(
String
email
,
String
password
)
{
_specification
.
AddInclude
(
e
=>
e
.
Employee
);
_specification
.
AddInclude
(
e
=>
e
.
Employee
);
_specification
.
AddInclude
(
e
=>
e
.
Roles
);
_specification
.
AddInclude
(
e
=>
e
.
Roles
);
User
u
=
await
_userRepository
.
GetByEmail
(
email
,
_specification
);
User
u
=
await
_userRepository
.
GetByEmail
(
email
,
_specification
);
if
(
u
is
null
||
u
.
HashedPassword
!=
password
)
{
if
(
u
is
null
||
u
.
HashedPassword
!=
hashPassword
(
password
))
{
return
Result
.
Invalid
(
UserErrors
.
InvalidLoginAttempt
);
return
Result
.
Invalid
(
UserErrors
.
InvalidLoginAttempt
);
}
}
String
token
=
_jwtTokenGenerator
.
GenerateToken
(
u
);
String
token
=
_jwtTokenGenerator
.
GenerateToken
(
u
);
return
new
AuthenticationResult
{
return
new
AuthenticationResult
{
...
@@ -47,12 +57,18 @@ namespace PSManagement.Infrastructure.Services.Authentication
...
@@ -47,12 +57,18 @@ namespace PSManagement.Infrastructure.Services.Authentication
Roles
=
_mapper
.
Map
<
ICollection
<
RoleDTO
>>(
u
.
Roles
),
Roles
=
_mapper
.
Map
<
ICollection
<
RoleDTO
>>(
u
.
Roles
),
Token
=
token
};
Token
=
token
};
}
}
#
endregion
Login
#
region
Registeration
public
async
Task
<
Result
<
AuthenticationResult
>>
Register
(
String
email
,
String
userName
,
String
password
)
{
public
async
Task
<
Result
<
AuthenticationResult
>>
Register
(
String
email
,
String
userName
,
String
password
)
{
// check if the user exist
// check if the user exist
var
u
=
await
_userRepository
.
GetByEmail
(
email
);
var
u
=
await
_userRepository
.
GetByEmail
(
email
);
if
(
u
is
not
null
)
{
if
(
u
is
not
null
)
{
return
Result
.
Invalid
(
UserErrors
.
AlreadyUserExist
);
return
Result
.
Invalid
(
UserErrors
.
AlreadyUserExist
);
}
}
var
user
=
await
_userRepository
.
AddAsync
(
var
user
=
await
_userRepository
.
AddAsync
(
new
User
{
new
User
{
Email
=
email
,
Email
=
email
,
...
@@ -74,6 +90,14 @@ namespace PSManagement.Infrastructure.Services.Authentication
...
@@ -74,6 +90,14 @@ namespace PSManagement.Infrastructure.Services.Authentication
}
}
#
endregion
Registeration
#
region
Password
Hasher
private
string
hashPassword
(
string
passsword
)
{
return
passsword
;
}
#
endregion
Password
Hasher
}
}
...
...
PSManagement.Infrastructure/DependencyInjectionConfiguration/DependencyInjection.cs
View file @
0f8a3073
...
@@ -37,6 +37,8 @@ namespace PSManagement.Infrastructure.DI
...
@@ -37,6 +37,8 @@ namespace PSManagement.Infrastructure.DI
return
services
;
return
services
;
}
}
#
region
Add
Servcies
private
static
IServiceCollection
AddServices
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
private
static
IServiceCollection
AddServices
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
{
services
.
Configure
<
FileServiceSettings
>(
configuration
.
GetSection
(
FileServiceSettings
.
SectionName
));
services
.
Configure
<
FileServiceSettings
>(
configuration
.
GetSection
(
FileServiceSettings
.
SectionName
));
...
@@ -49,9 +51,13 @@ namespace PSManagement.Infrastructure.DI
...
@@ -49,9 +51,13 @@ namespace PSManagement.Infrastructure.DI
services
.
AddScoped
<
IEmailService
,
EmailService
>();
services
.
AddScoped
<
IEmailService
,
EmailService
>();
return
services
;
return
services
;
}
}
#
endregion
Add
Servcies
#
region
Background
jobs
private
static
IServiceCollection
AddBackgroundServices
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
private
static
IServiceCollection
AddBackgroundServices
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
{
services
.
Configure
<
EmployeesSyncJobSettings
>(
configuration
.
GetSection
(
"EmpoyeesSyncJobSettings"
));
services
.
Configure
<
EmployeesSyncJobSettings
>(
configuration
.
GetSection
(
EmployeesSyncJobSettings
.
SectionName
));
services
.
AddSingleton
<
IHttpContextAccessor
,
HttpContextAccessor
>();
services
.
AddSingleton
<
IHttpContextAccessor
,
HttpContextAccessor
>();
services
.
AddScoped
<
ISyncEmployeesService
,
SyncEmployeesService
>();
services
.
AddScoped
<
ISyncEmployeesService
,
SyncEmployeesService
>();
...
@@ -61,7 +67,9 @@ namespace PSManagement.Infrastructure.DI
...
@@ -61,7 +67,9 @@ namespace PSManagement.Infrastructure.DI
return
services
;
return
services
;
}
}
#
endregion
Background
jobs
#
region
Authorization
private
static
IServiceCollection
AddAuthorization
(
this
IServiceCollection
services
)
private
static
IServiceCollection
AddAuthorization
(
this
IServiceCollection
services
)
{
{
services
.
AddScoped
<
IUserRoleService
,
UserRolesService
>();
services
.
AddScoped
<
IUserRoleService
,
UserRolesService
>();
...
@@ -69,7 +77,9 @@ namespace PSManagement.Infrastructure.DI
...
@@ -69,7 +77,9 @@ namespace PSManagement.Infrastructure.DI
return
services
;
return
services
;
}
}
#
endregion
Authorization
#
region
Authentication
private
static
IServiceCollection
AddAuthentication
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
private
static
IServiceCollection
AddAuthentication
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
{
services
.
Configure
<
JwtSetting
>(
configuration
.
GetSection
(
JwtSetting
.
Section
));
services
.
Configure
<
JwtSetting
>(
configuration
.
GetSection
(
JwtSetting
.
Section
));
...
@@ -84,5 +94,6 @@ namespace PSManagement.Infrastructure.DI
...
@@ -84,5 +94,6 @@ namespace PSManagement.Infrastructure.DI
return
services
;
return
services
;
}
}
#
endregion
Authentication
}
}
}
}
PSManagement.Infrastructure/Settings/EmployeesSyncJobSettings.cs
View file @
0f8a3073
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
{
{
public
class
EmployeesSyncJobSettings
public
class
EmployeesSyncJobSettings
{
{
public
const
string
SectionName
=
"EmpoyeesSyncJobSettings"
;
public
int
SyncIntervalInMinutes
{
get
;
set
;
}
public
int
SyncIntervalInMinutes
{
get
;
set
;
}
}
}
}
}
PSManagement.Infrastructure/SyncData/SyncEmployeesService.cs
View file @
0f8a3073
...
@@ -44,11 +44,15 @@ namespace PSManagement.Infrastructure.BackgroundServcies
...
@@ -44,11 +44,15 @@ namespace PSManagement.Infrastructure.BackgroundServcies
public
async
Task
<
SyncResponse
>
SyncEmployees
(
IEmployeesProvider
employeesProvider
)
public
async
Task
<
SyncResponse
>
SyncEmployees
(
IEmployeesProvider
employeesProvider
)
{
{
IEnumerable
<
Employee
>
NewestEmployees
=
await
_employeesProviders
.
FetchEmployees
();
IEnumerable
<
Employee
>
NewestEmployees
=
await
_employeesProviders
.
FetchEmployees
();
int
count
=
0
;
int
count
=
0
;
foreach
(
Employee
employee
in
NewestEmployees
)
{
foreach
(
Employee
employee
in
NewestEmployees
)
{
_specification
.
Criteria
=
empl
=>
empl
.
HIASTId
==
employee
.
HIASTId
;
_specification
.
Criteria
=
empl
=>
empl
.
HIASTId
==
employee
.
HIASTId
;
Employee
emp
=
_employeesRepository
.
ListAsync
(
_specification
).
Result
.
FirstOrDefault
();
Employee
emp
=
_employeesRepository
.
ListAsync
(
_specification
).
Result
.
FirstOrDefault
();
if
(
emp
is
null
)
{
if
(
emp
is
null
)
{
emp
=
await
_employeesRepository
.
AddAsync
(
employee
);
emp
=
await
_employeesRepository
.
AddAsync
(
employee
);
...
...
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