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
bca956a3
Commit
bca956a3
authored
Aug 17, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix s.
parent
5e095f70
Changes
42
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
2871 additions
and
135 deletions
+2871
-135
CustomersController.cs
...nagement.Api/Controllers/Customers/CustomersController.cs
+38
-9
CustomerMapperConfiguration.cs
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
+4
-4
ValidationBehavior.cs
...cation/Behaviors/ValidationBehavior/ValidationBehavior.cs
+5
-27
CustomerCreatedEventHandler.cs
...plication/Customers/Events/CustomerCreatedEventHandler.cs
+17
-2
RemoveContactInfoCommand.cs
...es/Commands/RemoveContactInfo/RemoveContactInfoCommand.cs
+10
-0
RemoveContactInfoCommandHandler.cs
...ands/RemoveContactInfo/RemoveContactInfoCommandHandler.cs
+46
-0
UpdateCustomerCommandHandler.cs
...s/Commands/UpdateCustomer/UpdateCustomerCommandHandler.cs
+4
-2
GetCustomerQuery.cs
...mers/UseCases/Queries/GetCustomerById/GetCustomerQuery.cs
+1
-1
GetCustomerQueryHandler.cs
...eCases/Queries/GetCustomerById/GetCustomerQueryHandler.cs
+9
-2
EmployeeDTO.cs
PSManagement.Application/Employees/Common/EmployeeDTO.cs
+1
-0
GetEmployeeByIdQueryHandler.cs
...es/Queries/GetEmployeeById/GetEmployeeByIdQueryHandler.cs
+1
-1
GetEmployeeParticipationQueryHandler.cs
...yeeParticipations/GetEmployeeParticipationQueryHandler.cs
+2
-0
CreateFinancialSpendItemCommandHandler.cs
...ancialSpendItem/CreateFinancialSpendItemCommandHandler.cs
+2
-6
PSManagement.Application.csproj
PSManagement.Application/PSManagement.Application.csproj
+0
-1
AddParticipantCommandHandler.cs
...s/Commands/AddParticipant/AddParticipantCommandHandler.cs
+4
-1
CancelProjectCommandHandler.cs
...ses/Commands/CancelProject/CancelProjectCommandHandler.cs
+6
-4
RemoveParticipantCommandHandler.cs
...ands/RemoveParticipant/RemoveParticipantCommandHandler.cs
+19
-12
UpdateEmployeeWorkTrackCommandHandler.cs
...mployeeWorkTrack/UpdateEmployeeWorkTrackCommandHandler.cs
+3
-8
AddContactInfoRequest.cs
...ent.Contracts/Customers/Requests/AddContactInfoRequest.cs
+1
-0
RemoveContactInfoRequest.cs
....Contracts/Customers/Requests/RemoveContactInfoRequest.cs
+7
-0
ContactInfoResponse.cs
...ment.Contracts/Customers/Responses/ContactInfoResponse.cs
+1
-1
CustomerResponse.cs
...agement.Contracts/Customers/Responses/CustomerResponse.cs
+3
-3
ListCustomersResponse.cs
...nt.Contracts/Customers/Responses/ListCustomersResponse.cs
+1
-1
EmployeeResponse.cs
...nagement.Contracts/Employees/Response/EmployeeResponse.cs
+1
-0
ProjectResponse.cs
PSManagement.Contracts/Projects/Response/ProjectResponse.cs
+1
-1
CustomerSpecification.cs
...t.Domain/Customers/Specification/CustomerSpecification.cs
+16
-0
Address.cs
PSManagement.Domain/Customers/ValueObjects/Address.cs
+0
-1
ProjectBuilder.cs
PSManagement.Domain/Projects/Builders/ProjectBuilder.cs
+1
-0
Project.cs
PSManagement.Domain/Projects/Entities/Project.cs
+8
-7
CancledState.cs
PSManagement.Domain/Projects/States/CancledState.cs
+2
-1
CompletedState.cs
PSManagement.Domain/Projects/States/CompletedState.cs
+2
-1
IProjectState.cs
PSManagement.Domain/Projects/States/IProjectState.cs
+2
-1
InPlanState.cs
PSManagement.Domain/Projects/States/InPlanState.cs
+1
-1
InProgressState.cs
PSManagement.Domain/Projects/States/InProgressState.cs
+2
-2
ProposedState.cs
PSManagement.Domain/Projects/States/ProposedState.cs
+2
-1
CustomerEntityConfiguration.cs
...ence/EntitiesConfiguration/CustomerEntityConfiguration.cs
+1
-2
ProjectEntityConfiguration.cs
...tence/EntitiesConfiguration/ProjectEntityConfiguration.cs
+7
-1
20240817114741_FixCustomerEntity.Designer.cs
...e/Migrations/20240817114741_FixCustomerEntity.Designer.cs
+1240
-0
20240817114741_FixCustomerEntity.cs
...ersistence/Migrations/20240817114741_FixCustomerEntity.cs
+92
-0
20240817134029_FixProjectEntity.Designer.cs
...ce/Migrations/20240817134029_FixProjectEntity.Designer.cs
+1240
-0
20240817134029_FixProjectEntity.cs
...Persistence/Migrations/20240817134029_FixProjectEntity.cs
+35
-0
AppDbContextModelSnapshot.cs
...cture.Persistence/Migrations/AppDbContextModelSnapshot.cs
+33
-31
No files found.
PSManagement.Api/Controllers/Customers/CustomersController.cs
View file @
bca956a3
...
...
@@ -18,6 +18,7 @@ using PSManagement.Contracts.Customers.Responses;
using
PSManagement.Application.Customers.UseCases.Queries.GetCustomer
;
using
PSManagement.Api.Controllers.ApiBase
;
using
Ardalis.Result
;
using
PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo
;
namespace
PSManagement.Api.Controllers.Customers
{
...
...
@@ -35,36 +36,53 @@ namespace PSManagement.Api.Controllers.Customers
}
[
HttpGet
]
public
async
Task
<
IActionResult
>
ListCustomers
()
public
async
Task
<
IActionResult
>
Get
()
{
var
query
=
new
ListAllCustomersQuery
();
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
CustomerRe
cord
>>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
CustomerRe
sponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpGet
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Get
Customer
(
int
id
)
public
async
Task
<
IActionResult
>
Get
(
int
id
)
{
var
query
=
new
GetCustomerQuery
(
id
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
CustomerRe
cord
>>(
result
));
return
Ok
(
_mapper
.
Map
<
Result
<
CustomerRe
sponse
>>(
result
));
}
[
HttpPost
]
public
async
Task
<
IActionResult
>
CreateCustomer
(
CreateCustomerRequest
request
)
public
async
Task
<
IActionResult
>
Post
(
CreateCustomerRequest
request
)
{
var
command
=
_mapper
.
Map
<
CreateCustomerCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
if
(
result
.
IsSuccess
)
{
var
query
=
new
GetCustomerQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
CustomerResponse
>(
response
));
}
else
{
return
Ok
(
result
);
}
}
[
HttpDelete
]
public
async
Task
<
IActionResult
>
Delete
Customer
(
DeleteCustomerRequest
request
)
public
async
Task
<
IActionResult
>
Delete
(
DeleteCustomerRequest
request
)
{
var
command
=
_mapper
.
Map
<
DeleteCustomerCommand
>(
request
);
...
...
@@ -73,8 +91,9 @@ namespace PSManagement.Api.Controllers.Customers
return
Ok
(
result
);
}
[
HttpPut
(
"{id}"
)]
public
async
Task
<
IActionResult
>
UpdateCustomer
(
int
id
,
UpdateCustomerRequest
request
)
public
async
Task
<
IActionResult
>
Put
(
int
id
,
UpdateCustomerRequest
request
)
{
if
(
id
!=
request
.
CustomerId
){
return
Problem
();
...
...
@@ -89,7 +108,7 @@ namespace PSManagement.Api.Controllers.Customers
[
HttpPost
(
"AddContactInfo"
)]
public
async
Task
<
IActionResult
>
Add
ContactInfo
(
AddContactInfoRequest
request
)
public
async
Task
<
IActionResult
>
Post
ContactInfo
(
AddContactInfoRequest
request
)
{
var
command
=
_mapper
.
Map
<
AddContactInfoCommand
>(
request
);
...
...
@@ -99,6 +118,16 @@ namespace PSManagement.Api.Controllers.Customers
}
[
HttpDelete
(
"RemoveContactInfo"
)]
public
async
Task
<
IActionResult
>
DeleteContactInfo
(
RemoveContactInfoRequest
request
)
{
var
command
=
_mapper
.
Map
<
RemoveContactInfoCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
}
}
}
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
View file @
bca956a3
...
...
@@ -32,12 +32,12 @@ namespace PSManagement.Api.Mappers
CreateMap
<
UpdateCustomerCommand
,
UpdateCustomerRequest
>().
ReverseMap
();
CreateMap
<
AddContactInfoRequest
,
AddContactInfoCommand
>().
ReverseMap
();
CreateMap
<
CustomerDTO
,
CustomerRe
cord
>();
CreateMap
<
ContactInfoDTO
,
ContactInfoRe
cord
>();
CreateMap
<
CustomerDTO
,
CustomerRe
sponse
>();
CreateMap
<
ContactInfoDTO
,
ContactInfoRe
sponse
>();
CreateMap
<
CustomerRe
cord
,
CustomerDTO
>().
ReverseMap
();
CreateMap
<
CustomerRe
sponse
,
CustomerDTO
>().
ReverseMap
();
CreateMap
<
IEnumerable
<
CustomerRe
cord
>,
ListCustomersResponse
>()
CreateMap
<
IEnumerable
<
CustomerRe
sponse
>,
ListCustomersResponse
>()
.
ConstructUsing
(
src
=>
new
ListCustomersResponse
(
src
));
}
...
...
PSManagement.Application/Behaviors/ValidationBehavior/ValidationBehavior.cs
View file @
bca956a3
...
...
@@ -13,7 +13,7 @@ namespace PSManagement.Application.Behaviors.ValidationBehavior
{
public
class
ValidationBehavior
<
TRequest
,
TResponse
>
:
IPipelineBehavior
<
TRequest
,
TResponse
>
where
TRequest
:
IRequest
<
TResponse
>
where
TRequest
:
IRequest
<
TResponse
>
{
private
readonly
IEnumerable
<
IValidator
<
TRequest
>>
_validators
;
...
...
@@ -23,8 +23,9 @@ namespace PSManagement.Application.Behaviors.ValidationBehavior
}
public
async
Task
<
TResponse
>
Handle
(
TRequest
request
,
CancellationToken
cancellationToken
,
RequestHandlerDelegate
<
TResponse
>
next
)
{
if
(
_validators
is
null
)
{
{
if
(
_validators
is
null
)
{
return
await
next
();
}
...
...
@@ -34,7 +35,7 @@ namespace PSManagement.Application.Behaviors.ValidationBehavior
var
errors
=
validationResults
.
SelectMany
(
r
=>
r
.
Errors
)
.
Where
(
e
=>
e
!=
null
)
.
Select
(
e
=>
new
ValidationError
(
e
.
ErrorCode
,
e
.
ErrorMessage
,
e
.
ErrorCode
,
new
ValidationSeverity
()))
.
Select
(
e
=>
new
ValidationError
(
e
.
ErrorCode
,
e
.
ErrorMessage
,
e
.
ErrorCode
,
new
ValidationSeverity
()))
.
ToList
();
if
(
errors
.
Any
())
...
...
@@ -45,28 +46,5 @@ namespace PSManagement.Application.Behaviors.ValidationBehavior
return
await
next
();
}
private
Result
ValidateAsync
(
TRequest
request
)
{
var
context
=
new
ValidationContext
<
TRequest
>(
request
);
var
failures
=
_validators
.
Select
(
v
=>
v
.
Validate
(
context
))
.
SelectMany
(
result
=>
result
.
Errors
)
.
Where
(
f
=>
f
!=
null
)
.
ToList
();
if
(
failures
.
Count
!=
0
)
{
var
result
=
Result
.
Invalid
(
new
ValidationError
(
"validation Error."
));
//foreach (var failure in failures)
//{
// result.Reasons.Add(new Error(failure.ErrorMessage));
//}
return
result
;
}
return
Result
.
Success
();
}
}
}
PSManagement.Application/Customers/Events/CustomerCreatedEventHandler.cs
View file @
bca956a3
using
PSManagement.Domain.Customers.DomainEvents
;
using
Microsoft.Extensions.Logging
;
using
PSManagement.Application.Contracts.Providers
;
using
PSManagement.Domain.Customers.DomainEvents
;
using
PSManagement.Domain.Customers.Entities
;
using
PSManagement.SharedKernel.DomainEvents
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -11,10 +14,22 @@ namespace PSManagement.Application.Customers.Events
{
public
class
CustomerCreatedEventHandler
:
IDomainEventHandler
<
CutsomerCreatedEvent
>
{
private
readonly
ILogger
<
Customer
>
_logger
;
private
readonly
IDateTimeProvider
_dateTimeProvider
;
public
CustomerCreatedEventHandler
(
ILogger
<
Customer
>
logger
,
IDateTimeProvider
dateTimeProvider
)
{
_logger
=
logger
;
_dateTimeProvider
=
dateTimeProvider
;
}
public
Task
Handle
(
CutsomerCreatedEvent
notification
,
CancellationToken
cancellationToken
)
{
Console
.
WriteLine
(
"fdgfg"
);
_logger
.
LogInformation
(
"new customer Added at "
+
_dateTimeProvider
.
UtcNow
);
return
Task
.
CompletedTask
;
}
...
...
PSManagement.Application/Customers/UseCases/Commands/RemoveContactInfo/RemoveContactInfoCommand.cs
0 → 100644
View file @
bca956a3
using
Ardalis.Result
;
using
PSManagement.SharedKernel.CQRS.Command
;
namespace
PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo
{
public
record
RemoveContactInfoCommand
(
int
Id
,
int
CustomerId
)
:
ICommand
<
Result
>;
}
PSManagement.Application/Customers/UseCases/Commands/RemoveContactInfo/RemoveContactInfoCommandHandler.cs
0 → 100644
View file @
bca956a3
using
Ardalis.Result
;
using
PSManagement.Domain.Customers.DomainErrors
;
using
PSManagement.Domain.Customers.Entities
;
using
PSManagement.Domain.Customers.Repositories
;
using
PSManagement.SharedKernel.CQRS.Command
;
using
PSManagement.SharedKernel.Repositories
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo
{
public
class
RemoveContactInfoCommandHandler
:
ICommandHandler
<
RemoveContactInfoCommand
,
Result
>
{
private
readonly
ICustomersRepository
_customersRepository
;
private
readonly
IRepository
<
ContactInfo
>
_contactsRepository
;
public
RemoveContactInfoCommandHandler
(
ICustomersRepository
customersRepository
,
IRepository
<
ContactInfo
>
contactsRepository
)
{
_customersRepository
=
customersRepository
;
_contactsRepository
=
contactsRepository
;
}
public
async
Task
<
Result
>
Handle
(
RemoveContactInfoCommand
request
,
CancellationToken
cancellationToken
)
{
Customer
customer
=
await
_customersRepository
.
GetByIdAsync
(
request
.
CustomerId
);
if
(
customer
is
null
)
{
return
Result
.
Invalid
(
CustomerErrors
.
InvalidEntryError
);
}
ContactInfo
contact
=
await
_contactsRepository
.
GetByIdAsync
(
request
.
Id
);
if
(
contact
is
null
)
{
return
Result
.
Invalid
(
CustomerErrors
.
InvalidEntryError
);
}
await
_contactsRepository
.
DeleteAsync
(
contact
);
return
Result
.
Success
();
}
}
}
PSManagement.Application/Customers/UseCases/Commands/UpdateCustomer/UpdateCustomerCommandHandler.cs
View file @
bca956a3
...
...
@@ -27,8 +27,10 @@ namespace PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
public
async
Task
<
Result
>
Handle
(
UpdateCustomerCommand
request
,
CancellationToken
cancellationToken
)
{
Customer
customer
=
new
(
request
.
CustomerName
,
request
.
Address
,
request
.
Email
);
customer
.
Id
=
request
.
CustomerId
;
Customer
customer
=
await
_customerRepository
.
GetByIdAsync
(
request
.
CustomerId
);
customer
.
Email
=
request
.
Email
;
customer
.
CustomerName
=
request
.
CustomerName
;
customer
.
Address
=
request
.
Address
;
await
_customerRepository
.
UpdateAsync
(
customer
);
...
...
PSManagement.Application/Customers/UseCases/Queries/GetCustomerById/GetCustomerQuery.cs
View file @
bca956a3
...
...
@@ -7,6 +7,6 @@ using System.Text;
namespace
PSManagement.Application.Customers.UseCases.Queries.GetCustomer
{
public
record
GetCustomerQuery
(
int
c
ustomerId
)
:
IQuery
<
Result
<
CustomerDTO
>>;
public
record
GetCustomerQuery
(
int
C
ustomerId
)
:
IQuery
<
Result
<
CustomerDTO
>>;
}
PSManagement.Application/Customers/UseCases/Queries/GetCustomerById/GetCustomerQueryHandler.cs
View file @
bca956a3
...
...
@@ -4,7 +4,9 @@ using PSManagement.Application.Customers.Common;
using
PSManagement.Domain.Customers.DomainErrors
;
using
PSManagement.Domain.Customers.Entities
;
using
PSManagement.Domain.Customers.Repositories
;
using
PSManagement.Domain.Customers.Specification
;
using
PSManagement.SharedKernel.CQRS.Query
;
using
PSManagement.SharedKernel.Specification
;
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -15,18 +17,23 @@ namespace PSManagement.Application.Customers.UseCases.Queries.GetCustomer
{
private
readonly
ICustomersRepository
_customersRepository
;
private
readonly
IMapper
_mapper
;
private
readonly
BaseSpecification
<
Customer
>
_specification
;
public
GetCustomerQueryHandler
(
ICustomersRepository
customersRepository
,
IMapper
mapper
)
{
_customersRepository
=
customersRepository
;
_mapper
=
mapper
;
_specification
=
new
CustomerSpecification
();
}
public
async
Task
<
Result
<
CustomerDTO
>>
Handle
(
GetCustomerQuery
request
,
CancellationToken
cancellationToken
)
{
Customer
customer
=
await
_customersRepository
.
GetByIdAsync
(
request
.
customerId
);
Customer
customer
=
await
_customersRepository
.
GetByIdAsync
(
request
.
CustomerId
,
_specification
);
if
(
customer
is
null
)
{
return
Result
.
NotFound
(
CustomerErrors
.
InvalidEntryError
.
ErrorMessage
);
return
Result
.
Invalid
(
CustomerErrors
.
InvalidEntryError
);
}
return
Result
.
Success
(
_mapper
.
Map
<
CustomerDTO
>(
customer
));
}
...
...
PSManagement.Application/Employees/Common/EmployeeDTO.cs
View file @
bca956a3
...
...
@@ -15,6 +15,7 @@ namespace PSManagement.Application.Employees.Common
public
String
DepartmentName
{
get
;
set
;
}
public
PersonalInfo
PersonalInfo
{
get
;
set
;
}
public
WorkInfo
WorkInfo
{
get
;
set
;
}
public
Availability
Availability
{
get
;
set
;
}
}
}
PSManagement.Application/Employees/UseCases/Queries/GetEmployeeById/GetEmployeeByIdQueryHandler.cs
View file @
bca956a3
...
...
@@ -28,7 +28,7 @@ namespace PSManagement.Application.Employees.UseCases.Queries.GetEmployeeById
public
async
Task
<
Result
<
EmployeeDTO
>>
Handle
(
GetEmployeeByIdQuery
request
,
CancellationToken
cancellationToken
)
{
_specification
.
AddInclude
(
e
=>
e
.
Department
);
return
Result
.
Success
(
_mapper
.
Map
<
EmployeeDTO
>(
await
_employeesRepository
.
GetByIdAsync
(
request
.
EmployeeId
,
_specification
)));
}
}
...
...
PSManagement.Application/Employees/UseCases/Queries/GetEmployeeParticipations/GetEmployeeParticipationQueryHandler.cs
View file @
bca956a3
...
...
@@ -38,6 +38,8 @@ namespace PSManagement.Application.Employees.UseCases.Queries.GetEmployeeById
_specification
.
AddInclude
(
"Employee.Department"
);
_specification
.
AddInclude
(
e
=>
e
.
Employee
);
_specification
.
AddInclude
(
e
=>
e
.
Employee
.
Department
);
IEnumerable
<
EmployeeParticipate
>
response
=
await
_employeesParticipateRepository
.
ListAsync
(
_specification
);
...
...
PSManagement.Application/FinancialSpends/UseCases/Commands/CreateFinancialSpendItem/CreateFinancialSpendItemCommandHandler.cs
View file @
bca956a3
...
...
@@ -17,21 +17,17 @@ namespace PSManagement.Application.FinancialSpends.UseCases.Commands.CreateFinan
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
IFinancialSpendingRepository
_spendRepository
;
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
IMapper
_mapper
;
public
CreateFinancialSpendItemCommandHandler
(
IFinancialSpendingRepository
spendRepository
,
IProjectsRepository
projectsRepository
,
IUnitOfWork
unitOfWork
,
IMapper
mapper
)
IUnitOfWork
unitOfWork
)
{
_spendRepository
=
spendRepository
;
_projectsRepository
=
projectsRepository
;
_unitOfWork
=
unitOfWork
;
_mapper
=
mapper
;
}
...
...
PSManagement.Application/PSManagement.Application.csproj
View file @
bca956a3
...
...
@@ -7,7 +7,6 @@
<ItemGroup>
<Folder Include="Behaviors\AuthorizationBehavior\" />
<Folder Include="Customers\UseCases\Commands\RemoveContactInfo\" />
<Folder Include="Tracks\EventsHandlers\" />
</ItemGroup>
...
...
PSManagement.Application/Projects/UseCases/Commands/AddParticipant/AddParticipantCommandHandler.cs
View file @
bca956a3
...
...
@@ -41,7 +41,8 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddParticipant
public
async
Task
<
Result
>
Handle
(
AddParticipantCommand
request
,
CancellationToken
cancellationToken
)
{
_specification
.
Includes
.
Add
(
p
=>
p
.
EmployeeParticipates
);
_specification
.
AddInclude
(
e
=>
e
.
EmployeeParticipates
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
,
_specification
);
if
(
project
is
null
)
{
...
...
@@ -54,12 +55,14 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddParticipant
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantExistError
);
}
else
{
Employee
employee
=
await
_employeesRepository
.
GetByIdAsync
(
request
.
ParticipantId
);
if
(
employee
is
null
)
{
return
Result
.
Invalid
(
EmployeesErrors
.
EmployeeUnExist
);
}
await
_employeeParticipateRepository
.
AddAsync
(
new
(
request
.
ParticipantId
,
request
.
ProjectId
,
request
.
Role
,
request
.
PartialTimeRatio
));
project
.
AddDomainEvent
(
new
ParticipantAddedEvent
(
request
.
ParticipantId
,
request
.
ProjectId
,
request
.
PartialTimeRatio
,
request
.
Role
));
...
...
PSManagement.Application/Projects/UseCases/Commands/CancelProject/CancelProjectCommandHandler.cs
View file @
bca956a3
using
Ardalis.Result
;
using
PSManagement.Application.Contracts.Providers
;
using
PSManagement.Domain.Projects.DomainErrors
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
...
...
@@ -13,16 +14,17 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CancelProject
{
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
IDateTimeProvider
_dateTime
;
public
CancelProjectCommandHandler
(
IProjectsRepository
projectsRepository
,
IUnitOfWork
unitOfWork
)
IUnitOfWork
unitOfWork
,
IDateTimeProvider
dateTime
)
{
_projectsRepository
=
projectsRepository
;
_unitOfWork
=
unitOfWork
;
_dateTime
=
dateTime
;
}
public
async
Task
<
Result
>
Handle
(
CancelProjectCommand
request
,
CancellationToken
cancellationToken
)
...
...
@@ -35,7 +37,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CancelProject
else
{
project
.
Canc
le
(
);
project
.
Canc
el
(
_dateTime
.
UtcNow
);
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
();
...
...
PSManagement.Application/Projects/UseCases/Commands/RemoveParticipant/RemoveParticipantCommandHandler.cs
View file @
bca956a3
using
Ardalis.Result
;
using
PSManagement.Domain.Projects
;
using
PSManagement.Domain.Projects.DomainErrors
;
using
PSManagement.Domain.Projects.DomainEvents
;
using
PSManagement.Domain.Projects.Entities
;
...
...
@@ -6,6 +7,7 @@ using PSManagement.Domain.Projects.Repositories;
using
PSManagement.SharedKernel.CQRS.Command
;
using
PSManagement.SharedKernel.Interfaces
;
using
PSManagement.SharedKernel.Repositories
;
using
PSManagement.SharedKernel.Specification
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -17,6 +19,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
private
readonly
IProjectsRepository
_projectsRepository
;
private
readonly
IRepository
<
EmployeeParticipate
>
_employeeParticipateRepository
;
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
BaseSpecification
<
Project
>
_specification
;
public
AddParticipantCommandHandler
(
IRepository
<
EmployeeParticipate
>
repository
,
...
...
@@ -24,37 +27,41 @@ namespace PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
IUnitOfWork
unitOfWork
)
{
_employeeParticipateRepository
=
repository
;
_specification
=
new
ProjectSpecification
();
_projectsRepository
=
projectsRepository
;
_unitOfWork
=
unitOfWork
;
}
public
async
Task
<
Result
>
Handle
(
RemoveParticipantCommand
request
,
CancellationToken
cancellationToken
)
{
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
);
_specification
.
AddInclude
(
e
=>
e
.
EmployeeParticipates
);
Project
project
=
await
_projectsRepository
.
GetByIdAsync
(
request
.
ProjectId
,
_specification
);
if
(
project
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
}
else
{
if
(
project
.
EmployeeParticipates
is
null
)
{
if
(
project
.
EmployeeParticipates
?.
Where
(
e
=>
e
.
Id
==
request
.
ParticipantId
)
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantUnExistError
);
}
var
employeeParticipate
=
project
.
EmployeeParticipates
.
Where
(
e
=>
e
.
ProjectId
==
request
.
ParticipantId
).
FirstOrDefault
();
if
(
employeeParticipate
is
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantUnExistError
);
}
else
{
EmployeeParticipate
participant
=
await
_employeeParticipateRepository
.
GetByIdAsync
(
request
.
ParticipantId
);
await
_employeeParticipateRepository
.
DeleteAsync
(
participant
);
project
.
AddDomainEvent
(
new
ParticipantRemovedEvent
(
request
.
ParticipantId
,
request
.
ProjectId
));
await
_employeeParticipateRepository
.
DeleteAsync
(
employeeParticipate
);
project
.
AddDomainEvent
(
new
ParticipantRemovedEvent
(
request
.
ParticipantId
,
request
.
ProjectId
));
await
_unitOfWork
.
SaveChangesAsync
();
await
_unitOfWork
.
SaveChangesAsync
();
return
Result
.
Success
();
}
return
Result
.
Success
();
}
...
...
PSManagement.Application/Tracks/UseCaes/Commands/UpdateEmployeeWorkTrack/UpdateEmployeeWorkTrackCommandHandler.cs
View file @
bca956a3
...
...
@@ -15,19 +15,14 @@ namespace PSManagement.Application.Tracks.UseCaes.Commands.UpdateEmployeeWorkTra
{
private
readonly
IRepository
<
EmployeeTrack
>
_employeeTracksRepository
;
private
readonly
ITracksRepository
_tracksRepository
;
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
IMapper
_mapper
;
public
UpdateEmployeeWorkTrackCommandHandler
(
IUnitOfWork
unitOfWork
,
ITracksRepository
tracksRepository
,
IRepository
<
EmployeeTrack
>
employeeTracksRepository
,
IMapper
mapper
)
IRepository
<
EmployeeTrack
>
employeeTracksRepository
)
{
_unitOfWork
=
unitOfWork
;
_tracksRepository
=
tracksRepository
;
_employeeTracksRepository
=
employeeTracksRepository
;
_mapper
=
mapper
;
}
public
async
Task
<
Result
>
Handle
(
UpdateEmployeeWorkTrackCommand
request
,
CancellationToken
cancellationToken
)
...
...
PSManagement.Contracts/Customers/Requests/AddContactInfoRequest.cs
View file @
bca956a3
...
...
@@ -10,4 +10,5 @@ namespace PSManagement.Contracts.Customers.Requests
int
CustomerId
,
String
ContactType
,
String
ContactValue
);
}
PSManagement.Contracts/Customers/Requests/RemoveContactInfoRequest.cs
0 → 100644
View file @
bca956a3
namespace
PSManagement.Contracts.Customers.Requests
{
public
record
RemoveContactInfoRequest
(
int
Id
,
int
CustomerId
)
;
}
PSManagement.Contracts/Customers/Responses/ContactInfoRe
cord
.cs
→
PSManagement.Contracts/Customers/Responses/ContactInfoRe
sponse
.cs
View file @
bca956a3
...
...
@@ -2,7 +2,7 @@
namespace
PSManagement.Contracts.Customers.Responses
{
public
class
ContactInfoRe
cord
{
public
class
ContactInfoRe
sponse
{
public
String
ContactType
{
get
;
set
;
}
public
String
ContactValue
{
get
;
set
;
}
}
...
...
PSManagement.Contracts/Customers/Responses/CustomerRe
cord
.cs
→
PSManagement.Contracts/Customers/Responses/CustomerRe
sponse
.cs
View file @
bca956a3
...
...
@@ -5,8 +5,8 @@ using System.Collections.Generic;
namespace
PSManagement.Contracts.Customers.Responses
{
public
class
CustomerRe
cord
{
public
CustomerRe
cord
()
public
class
CustomerRe
sponse
{
public
CustomerRe
sponse
()
{
}
...
...
@@ -15,6 +15,6 @@ namespace PSManagement.Contracts.Customers.Responses
public
String
CustomerName
{
get
;
set
;
}
public
String
Email
{
get
;
set
;
}
public
Address
Address
{
get
;
set
;
}
public
IEnumerable
<
ContactInfoRe
cord
>
ContactInfo
{
get
;
set
;
}
public
IEnumerable
<
ContactInfoRe
sponse
>
ContactInfo
{
get
;
set
;
}
}
}
PSManagement.Contracts/Customers/Responses/ListCustomersResponse.cs
View file @
bca956a3
...
...
@@ -5,6 +5,6 @@ using System.Threading.Tasks;
namespace
PSManagement.Contracts.Customers.Responses
{
public
record
ListCustomersResponse
(
IEnumerable
<
CustomerRe
cord
>
Customers
);
public
record
ListCustomersResponse
(
IEnumerable
<
CustomerRe
sponse
>
Customers
);
}
PSManagement.Contracts/Employees/Response/EmployeeResponse.cs
View file @
bca956a3
...
...
@@ -9,6 +9,7 @@ namespace PSManagement.Contracts.Projects.Response
public
int
UserId
{
get
;
set
;
}
public
string
DepartmentName
{
get
;
set
;
}
public
PersonalInfo
PersonalInfo
{
get
;
set
;
}
public
Availability
Availability
{
get
;
set
;
}
public
WorkInfo
WorkInfo
{
get
;
set
;
}
}
}
\ No newline at end of file
PSManagement.Contracts/Projects/Response/ProjectResponse.cs
View file @
bca956a3
...
...
@@ -22,7 +22,7 @@ namespace PSManagement.Contracts.Projects.Response
public
Department
Executer
{
get
;
set
;
}
public
int
ProposerId
{
get
;
private
set
;
}
public
CustomerRe
cord
Proposer
{
get
;
set
;
}
public
CustomerRe
sponse
Proposer
{
get
;
set
;
}
public
ICollection
<
StepResponse
>
Steps
{
get
;
set
;
}
public
ICollection
<
Attachment
>
Attachments
{
get
;
set
;
}
...
...
PSManagement.Domain/Customers/Specification/CustomerSpecification.cs
0 → 100644
View file @
bca956a3
using
PSManagement.Domain.Customers.Entities
;
using
PSManagement.SharedKernel.Specification
;
using
System
;
using
System.Linq.Expressions
;
namespace
PSManagement.Domain.Customers.Specification
{
public
class
CustomerSpecification
:
BaseSpecification
<
Customer
>
{
public
CustomerSpecification
(
Expression
<
Func
<
Customer
,
bool
>>
criteria
=
null
)
:
base
(
criteria
)
{
AddInclude
(
e
=>
e
.
ContactInfo
);
}
}
}
PSManagement.Domain/Customers/ValueObjects/Address.cs
View file @
bca956a3
...
...
@@ -9,7 +9,6 @@ namespace PSManagement.Domain.Customers.ValueObjects
{
public
record
Address
(
int
StreetNumber
,
int
ZipCode
,
String
StreetName
,
String
City
);
}
PSManagement.Domain/Projects/Builders/ProjectBuilder.cs
View file @
bca956a3
...
...
@@ -89,6 +89,7 @@ namespace PSManagement.Domain.Projects.Builders
}
public
ProjectBuilder
WithAttachment
(
Attachment
[]
attachments
)
{
_attachments
=
new
List
<
Attachment
>();
foreach
(
Attachment
attachment
in
attachments
)
{
_attachments
.
Add
(
attachment
);
}
...
...
PSManagement.Domain/Projects/Entities/Project.cs
View file @
bca956a3
...
...
@@ -20,10 +20,11 @@ namespace PSManagement.Domain.Projects.Entities
public
ProposalInfo
ProposalInfo
{
get
;
set
;
}
public
ProjectInfo
ProjectInfo
{
get
;
set
;
}
public
Aggreement
ProjectAggreement
{
get
;
set
;
}
// state management
[
NotMapped
]
public
string
CurrentState
{
get
;
private
set
;
}
// Persisted in the database
[
NotMapped
]
private
IProjectState
_state
;
// information about who lead and execute the project
...
...
@@ -94,17 +95,17 @@ namespace PSManagement.Domain.Projects.Entities
Steps
=
new
List
<
Step
>();
Participants
=
new
List
<
Employee
>();
EmployeeParticipates
=
new
List
<
EmployeeParticipate
>();
}
public
Project
()
{
_state
=
new
ProposedState
();
CurrentState
=
_state
.
StateName
;
SetStateFromString
(
CurrentState
);
}
public
void
SetState
(
IProjectState
newState
)
{
_state
=
newState
;
CurrentState
=
_state
.
StateName
;
// Update the persisted state
CurrentState
=
_state
.
StateName
;
}
public
void
Complete
()
{
...
...
@@ -121,9 +122,9 @@ namespace PSManagement.Domain.Projects.Entities
_state
.
Approve
(
this
,
projectAggreement
);
}
public
void
Canc
le
(
)
public
void
Canc
el
(
DateTime
canellationTime
)
{
_state
.
Canc
le
(
this
);
_state
.
Canc
el
(
this
,
canellationTime
);
}
public
void
Propose
()
...
...
PSManagement.Domain/Projects/States/CancledState.cs
View file @
bca956a3
using
PSManagement.Domain.Projects.ValueObjects
;
using
System
;
namespace
PSManagement.Domain.Projects.Entities
{
...
...
@@ -11,7 +12,7 @@ namespace PSManagement.Domain.Projects.Entities
}
public
void
Canc
le
(
Project
project
)
public
void
Canc
el
(
Project
project
,
DateTime
canellationTime
)
{
}
...
...
PSManagement.Domain/Projects/States/CompletedState.cs
View file @
bca956a3
using
PSManagement.Domain.Projects.ValueObjects
;
using
System
;
namespace
PSManagement.Domain.Projects.Entities
{
...
...
@@ -11,7 +12,7 @@ namespace PSManagement.Domain.Projects.Entities
}
public
void
Canc
le
(
Project
project
)
public
void
Canc
el
(
Project
project
,
DateTime
canellationTime
)
{
}
...
...
PSManagement.Domain/Projects/States/IProjectState.cs
View file @
bca956a3
using
PSManagement.Domain.Projects.ValueObjects
;
using
System
;
namespace
PSManagement.Domain.Projects.Entities
{
...
...
@@ -7,7 +8,7 @@ namespace PSManagement.Domain.Projects.Entities
void
Complete
(
Project
project
);
void
Plan
(
Project
project
);
void
Approve
(
Project
project
,
Aggreement
projectAggreement
);
void
Canc
le
(
Project
project
);
void
Canc
el
(
Project
project
,
DateTime
canellationTime
);
void
Propose
(
Project
project
);
string
StateName
{
get
;
}
}
...
...
PSManagement.Domain/Projects/States/InPlanState.cs
View file @
bca956a3
...
...
@@ -16,7 +16,7 @@ namespace PSManagement.Domain.Projects.Entities
project
.
SetState
(
new
InProgressState
());
}
public
void
Canc
le
(
Project
project
)
public
void
Canc
el
(
Project
project
,
DateTime
canellationTime
)
{
project
.
AddDomainEvent
(
new
ProjectCancelledEvent
(
project
.
Id
,
DateTime
.
Now
));
project
.
SetState
(
new
CancledState
());
...
...
PSManagement.Domain/Projects/States/InProgressState.cs
View file @
bca956a3
...
...
@@ -13,9 +13,9 @@ namespace PSManagement.Domain.Projects.Entities
}
public
void
Canc
le
(
Project
project
)
public
void
Canc
el
(
Project
project
,
DateTime
canellationTime
)
{
project
.
AddDomainEvent
(
new
ProjectCancelledEvent
(
project
.
Id
,
DateTime
.
Now
));
project
.
AddDomainEvent
(
new
ProjectCancelledEvent
(
project
.
Id
,
canellationTime
));
project
.
SetState
(
new
CancledState
());
}
...
...
PSManagement.Domain/Projects/States/ProposedState.cs
View file @
bca956a3
using
PSManagement.Domain.Projects.ValueObjects
;
using
System
;
namespace
PSManagement.Domain.Projects.Entities
{
...
...
@@ -11,7 +12,7 @@ namespace PSManagement.Domain.Projects.Entities
}
public
void
Canc
le
(
Project
project
)
public
void
Canc
el
(
Project
project
,
DateTime
canellationTime
)
{
}
...
...
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/CustomerEntityConfiguration.cs
View file @
bca956a3
...
...
@@ -19,11 +19,10 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
address
.
Property
(
a
=>
a
.
StreetName
).
HasColumnName
(
"StreetName"
);
address
.
Property
(
a
=>
a
.
City
).
HasColumnName
(
"City"
);
address
.
Property
(
a
=>
a
.
StreetNumber
).
HasColumnName
(
"StreetNumber"
);
address
.
Property
(
a
=>
a
.
ZipCode
).
HasColumnName
(
"ZipCode"
);
}
);
builder
.
Own
sMany
(
c
=>
c
.
ContactInfo
);
builder
.
Ha
sMany
(
c
=>
c
.
ContactInfo
);
}
}
...
...
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/ProjectEntityConfiguration.cs
View file @
bca956a3
...
...
@@ -37,6 +37,7 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
}
);
builder
.
HasOne
(
e
=>
e
.
TeamLeader
)
.
WithMany
()
.
HasForeignKey
(
e
=>
e
.
TeamLeaderId
)
...
...
@@ -63,12 +64,17 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
}
);
builder
.
Property
(
p
=>
p
.
CurrentState
).
HasDefaultValue
(
"Proposed"
);
builder
.
Property
(
p
=>
p
.
CurrentState
)
.
HasDefaultValueSql
(
"Proposed"
)
;
builder
.
HasMany
(
e
=>
e
.
Attachments
).
WithOne
().
HasForeignKey
(
e
=>
e
.
ProjectId
);
builder
.
HasMany
(
e
=>
e
.
FinancialSpending
).
WithOne
().
HasForeignKey
(
e
=>
e
.
ProjectId
);
builder
.
HasMany
(
e
=>
e
.
Tracks
).
WithOne
(
e
=>
e
.
Project
).
HasForeignKey
(
e
=>
e
.
ProjectId
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240817114741_FixCustomerEntity.Designer.cs
0 → 100644
View file @
bca956a3
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240817114741_FixCustomerEntity.cs
0 → 100644
View file @
bca956a3
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
FixCustomerEntity
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_ContactInfo_Customers_CustomerId"
,
table
:
"ContactInfo"
);
migrationBuilder
.
DropPrimaryKey
(
name
:
"PK_ContactInfo"
,
table
:
"ContactInfo"
);
migrationBuilder
.
DropColumn
(
name
:
"ZipCode"
,
table
:
"Customers"
);
migrationBuilder
.
AlterColumn
<
int
>(
name
:
"CustomerId"
,
table
:
"ContactInfo"
,
type
:
"int"
,
nullable
:
true
,
oldClrType
:
typeof
(
int
),
oldType
:
"int"
);
migrationBuilder
.
AddPrimaryKey
(
name
:
"PK_ContactInfo"
,
table
:
"ContactInfo"
,
column
:
"Id"
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_ContactInfo_CustomerId"
,
table
:
"ContactInfo"
,
column
:
"CustomerId"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_ContactInfo_Customers_CustomerId"
,
table
:
"ContactInfo"
,
column
:
"CustomerId"
,
principalTable
:
"Customers"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Restrict
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_ContactInfo_Customers_CustomerId"
,
table
:
"ContactInfo"
);
migrationBuilder
.
DropPrimaryKey
(
name
:
"PK_ContactInfo"
,
table
:
"ContactInfo"
);
migrationBuilder
.
DropIndex
(
name
:
"IX_ContactInfo_CustomerId"
,
table
:
"ContactInfo"
);
migrationBuilder
.
AddColumn
<
int
>(
name
:
"ZipCode"
,
table
:
"Customers"
,
type
:
"int"
,
nullable
:
true
);
migrationBuilder
.
AlterColumn
<
int
>(
name
:
"CustomerId"
,
table
:
"ContactInfo"
,
type
:
"int"
,
nullable
:
false
,
defaultValue
:
0
,
oldClrType
:
typeof
(
int
),
oldType
:
"int"
,
oldNullable
:
true
);
migrationBuilder
.
AddPrimaryKey
(
name
:
"PK_ContactInfo"
,
table
:
"ContactInfo"
,
columns
:
new
[]
{
"CustomerId"
,
"Id"
});
migrationBuilder
.
AddForeignKey
(
name
:
"FK_ContactInfo_Customers_CustomerId"
,
table
:
"ContactInfo"
,
column
:
"CustomerId"
,
principalTable
:
"Customers"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240817134029_FixProjectEntity.Designer.cs
0 → 100644
View file @
bca956a3
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240817134029_FixProjectEntity.cs
0 → 100644
View file @
bca956a3
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
FixProjectEntity
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"CurrentState"
,
table
:
"Projects"
,
type
:
"nvarchar(max)"
,
nullable
:
true
,
defaultValueSql
:
"Proposed"
,
oldClrType
:
typeof
(
string
),
oldType
:
"nvarchar(max)"
,
oldNullable
:
true
,
oldDefaultValue
:
"Proposed"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AlterColumn
<
string
>(
name
:
"CurrentState"
,
table
:
"Projects"
,
type
:
"nvarchar(max)"
,
nullable
:
true
,
defaultValue
:
"Proposed"
,
oldClrType
:
typeof
(
string
),
oldType
:
"nvarchar(max)"
,
oldNullable
:
true
,
oldDefaultValueSql
:
"Proposed"
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs
View file @
bca956a3
...
...
@@ -20,6 +20,29 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.
HasAnnotation
(
"ProductVersion"
,
"5.0.17"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Entities.ContactInfo"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b
.
Property
<
string
>(
"ContactType"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
string
>(
"ContactValue"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
int
?>(
"CustomerId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"CustomerId"
);
b
.
ToTable
(
"ContactInfo"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Entities.Customer"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
...
...
@@ -281,7 +304,7 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
Property
<
string
>(
"CurrentState"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"nvarchar(max)"
)
.
HasDefaultValue
(
"Proposed"
);
.
HasDefaultValue
Sql
(
"Proposed"
);
b
.
Property
<
int
?>(
"CustomerId"
)
.
HasColumnType
(
"int"
);
...
...
@@ -553,32 +576,15 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
});
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Entities.C
ustomer
"
,
b
=>
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Entities.C
ontactInfo
"
,
b
=>
{
b
.
OwnsMany
(
"PSManagement.Domain.Customers.Entities.ContactInfo"
,
"ContactInfo"
,
b1
=>
{
b1
.
Property
<
int
>(
"CustomerId"
)
.
HasColumnType
(
"int"
);
b1
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b1
.
Property
<
string
>(
"ContactType"
)
.
HasColumnType
(
"nvarchar(max)"
);
b1
.
Property
<
string
>(
"ContactValue"
)
.
HasColumnType
(
"nvarchar(max)"
);
b1
.
HasKey
(
"CustomerId"
,
"Id"
);
b1
.
ToTable
(
"ContactInfo"
);
b1
.
WithOwner
()
.
HasForeignKey
(
"CustomerId"
);
});
b
.
HasOne
(
"PSManagement.Domain.Customers.Entities.Customer"
,
null
)
.
WithMany
(
"ContactInfo"
)
.
HasForeignKey
(
"CustomerId"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Entities.Customer"
,
b
=>
{
b
.
OwnsOne
(
"PSManagement.Domain.Customers.ValueObjects.Address"
,
"Address"
,
b1
=>
{
b1
.
Property
<
int
>(
"CustomerId"
)
...
...
@@ -598,10 +604,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.
HasColumnType
(
"int"
)
.
HasColumnName
(
"StreetNumber"
);
b1
.
Property
<
int
>(
"ZipCode"
)
.
HasColumnType
(
"int"
)
.
HasColumnName
(
"ZipCode"
);
b1
.
HasKey
(
"CustomerId"
);
b1
.
ToTable
(
"Customers"
);
...
...
@@ -611,8 +613,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
});
b
.
Navigation
(
"Address"
);
b
.
Navigation
(
"ContactInfo"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Employees.Entities.Employee"
,
b
=>
...
...
@@ -1181,6 +1181,8 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Entities.Customer"
,
b
=>
{
b
.
Navigation
(
"ContactInfo"
);
b
.
Navigation
(
"Projects"
);
});
...
...
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