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
c6a1b9ab
Commit
c6a1b9ab
authored
Aug 02, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix s .
parent
142bdb84
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1760 additions
and
22 deletions
+1760
-22
AuthenticationController.cs
...pi/Controllers/Authentication/AuthenticationController.cs
+4
-3
CustomersController.cs
...nagement.Api/Controllers/Customers/CustomersController.cs
+29
-3
DependencyInjection.cs
PSManagement.Api/DI/DependencyInjection.cs
+1
-1
CustomerMapperConfiguration.cs
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
+14
-0
MapperConfigurations.cs
PSManagement.Api/Mappers/MapperConfigurations.cs
+32
-0
PSManagement.Api.csproj
PSManagement.Api/PSManagement.Api.csproj
+1
-1
ContactInfoRecord.cs
...gement.Contracts/Customers/Responses/ContactInfoRecord.cs
+9
-0
CustomerRecord.cs
PSManagement.Contracts/Customers/Responses/CustomerRecord.cs
+19
-0
ListCustomersResponse.cs
...nt.Contracts/Customers/Responses/ListCustomersResponse.cs
+10
-0
PSManagement.Contracts.csproj
PSManagement.Contracts/PSManagement.Contracts.csproj
+0
-4
AppDbContext.cs
...Infrastructure.Persistence/AppDataContext/AppDbContext.cs
+20
-0
EmployeeEntityConfiguration.cs
...ence/EntitiesConfiguration/EmployeeEntityConfiguration.cs
+32
-0
ItemEntityConfiguration.cs
...sistence/EntitiesConfiguration/ItemEntityConfiguration.cs
+20
-0
ProjectEntityConfiguration.cs
...tence/EntitiesConfiguration/ProjectEntityConfiguration.cs
+37
-0
StepEntityConfiguration.cs
...sistence/EntitiesConfiguration/StepEntityConfiguration.cs
+15
-0
20240731070622_addCustomer4.Designer.cs
...stence/Migrations/20240731070622_addCustomer4.Designer.cs
+130
-0
20240731070622_addCustomer4.cs
...ure.Persistence/Migrations/20240731070622_addCustomer4.cs
+23
-0
20240801155515_AddDomains.Designer.cs
...sistence/Migrations/20240801155515_AddDomains.Designer.cs
+568
-0
20240801155515_AddDomains.cs
...cture.Persistence/Migrations/20240801155515_AddDomains.cs
+309
-0
AppDbContextModelSnapshot.cs
...cture.Persistence/Migrations/AppDbContextModelSnapshot.cs
+440
-2
AuthenticationService.cs
...tructure/Services/Authentication/AuthenticationService.cs
+6
-4
DomainError.cs
PSManagement.SharedKernel/DomainErrors/DomainError.cs
+24
-0
PSManagement.SharedKernel.csproj
PSManagement.SharedKernel/PSManagement.SharedKernel.csproj
+1
-1
Error.cs
PSManagement.SharedKernel/Utilities/Error.cs
+2
-2
Result.cs
PSManagement.SharedKernel/Utilities/Result.cs
+1
-1
Money.cs
PSManagement.SharedKernel/ValueObjects/Money.cs
+13
-0
No files found.
PSManagement.Api/Controllers/Authentication/AuthenticationController.cs
View file @
c6a1b9ab
using
FluentResults
;
using
FluentResults
;
using
Microsoft.AspNetCore.Mvc
;
using
PSManagement.Application.Contracts.Authentication
;
using
PSManagement.Contracts.Authentication
;
...
...
@@ -32,7 +33,7 @@ namespace PSManagement.Api.Controllers.Authentication
return
Ok
(
response
);
}
return
Problem
(
title
:
result
.
Errors
[
0
].
Message
,
detail
:
result
.
Errors
[
0
].
Reasons
[
0
]
.
Message
,
statusCode
:
400
);
return
Problem
(
title
:
result
.
Errors
[
0
].
Message
,
detail
:
result
.
Errors
[
0
].
Reasons
[
0
]
?.
Message
,
statusCode
:
401
);
}
[
HttpPost
(
"Register"
)]
public
async
Task
<
IActionResult
>
Register
([
FromBody
]
RegisterRequest
registerRequest
)
...
...
@@ -55,7 +56,7 @@ namespace PSManagement.Api.Controllers.Authentication
return
Ok
(
response
);
}
return
Problem
(
title
:
"An Errorr Occured "
+
result
.
Errors
[
0
].
Message
,
detail
:
result
.
Reasons
[
0
].
Message
,
statusCode
:
400
);
return
Problem
(
title
:
"An Errorr Occured "
,
detail
:
""
,
statusCode
:
400
);
}
}
...
...
PSManagement.Api/Controllers/Customers/CustomersController.cs
View file @
c6a1b9ab
...
...
@@ -13,12 +13,16 @@ using AutoMapper;
using
PSManagement.Application.Customers.UseCases.Commands.AddContactInfo
;
using
PSManagement.Application.Customers.UseCases.Commands.DeleteCustomer
;
using
PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
;
using
PSManagement.Application.Customers.UseCases.Queries.ListAllCustomers
;
using
PSManagement.Contracts.Customers.Responses
;
using
FluentResults
;
using
PSManagement.Application.Customers.UseCases.Queries.GetCustomer
;
namespace
PSManagement.Api.Controllers.Customers
{
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
Authorize
]
//
[Authorize]
public
class
CustomersController
:
ControllerBase
{
private
readonly
IMediator
_sender
;
...
...
@@ -30,6 +34,25 @@ namespace PSManagement.Api.Controllers.Customers
_mapper
=
mapper
;
}
[
HttpGet
]
public
async
Task
<
IActionResult
>
ListCustomers
()
{
var
query
=
new
ListAllCustomersQuery
();
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
CustomerRecord
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpGet
(
"{id}"
)]
public
async
Task
<
IActionResult
>
GetCustomer
(
int
id
)
{
var
query
=
new
GetCustomerQuery
(
id
);
var
result
=
_mapper
.
Map
<
Result
<
CustomerRecord
>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpPost
]
public
async
Task
<
IActionResult
>
CreateCustomer
(
CreateCustomerRequest
request
)
{
...
...
@@ -50,9 +73,12 @@ namespace PSManagement.Api.Controllers.Customers
return
Ok
(
result
);
}
[
HttpPut
]
public
async
Task
<
IActionResult
>
UpdateCustomer
(
UpdateCustomerRequest
request
)
[
HttpPut
(
"{id}"
)
]
public
async
Task
<
IActionResult
>
UpdateCustomer
(
int
id
,
UpdateCustomerRequest
request
)
{
if
(
id
!=
request
.
CustomerId
){
return
Problem
();
}
var
command
=
_mapper
.
Map
<
UpdateCustomerCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
...
...
PSManagement.Api/DI/DependencyInjection.cs
View file @
c6a1b9ab
...
...
@@ -21,7 +21,7 @@ namespace PSManagement.Api.DI
services
.
AddApiCors
();
services
.
AddScoped
<
Mapper
>();
services
.
AddAutoMapper
(
typeof
(
CustomerMapperConfiguration
));
services
.
AddAutoMapper
(
typeof
(
CustomerMapperConfiguration
)
,
typeof
(
MapperConfigurations
)
);
return
services
;
}
...
...
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
View file @
c6a1b9ab
...
...
@@ -4,6 +4,8 @@ using PSManagement.Application.Customers.UseCases.Commands.AddContactInfo;
using
PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
;
using
PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
;
using
PSManagement.Contracts.Customers.Requests
;
using
PSManagement.Contracts.Customers.Responses
;
using
PSManagement.SharedKernel.Utilities
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -20,7 +22,19 @@ namespace PSManagement.Api.Mappers
CreateMap
<
AddContactInfoRequest
,
AddContactInfoCommand
>().
ReverseMap
();
CreateMap
<
AddressRecord
,
AddressDTO
>().
ReverseMap
();
// CreateMap< IEnumerable<CustomerDTO>, ListCustomersResponse>().ma(src => src.Customers ,des => des.);
CreateMap
<
CustomerDTO
,
CustomerRecord
>();
CreateMap
<
ContactInfoDTO
,
ContactInfoRecord
>();
CreateMap
<
CustomerRecord
,
CustomerDTO
>().
ForMember
(
src
=>
src
.
ContactInfo
,
des
=>
des
.
Ignore
());
CreateMap
<
CustomerDTO
,
CustomerRecord
>()
.
ForMember
(
dest
=>
dest
.
CustomerName
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
CustomerName
))
.
ForMember
(
dest
=>
dest
.
Email
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Email
))
.
ForMember
(
dest
=>
dest
.
Address
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Address
));
CreateMap
<
IEnumerable
<
CustomerRecord
>,
ListCustomersResponse
>()
.
ConstructUsing
(
src
=>
new
ListCustomersResponse
(
src
));
}
}
}
PSManagement.Api/Mappers/MapperConfigurations.cs
0 → 100644
View file @
c6a1b9ab
using
AutoMapper
;
using
FluentResults
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
PSManagement.Api.Mappers
{
public
class
MapperConfigurations
:
Profile
{
public
MapperConfigurations
()
{
CreateMap
(
typeof
(
Result
<>),
typeof
(
Result
<>)).
ConvertUsing
(
typeof
(
ResultToResultConverter
<,>));
}
}
public
class
ResultToResultConverter
<
TSource
,
TDestination
>
:
ITypeConverter
<
Result
<
TSource
>,
Result
<
TDestination
>>
{
public
Result
<
TDestination
>
Convert
(
Result
<
TSource
>
source
,
Result
<
TDestination
>
destination
,
ResolutionContext
context
)
{
if
(
source
.
IsSuccess
)
{
var
mappedValue
=
context
.
Mapper
.
Map
<
TDestination
>(
source
.
Value
);
return
Result
.
Ok
(
mappedValue
);
}
else
{
return
Result
.
Fail
<
TDestination
>(
source
.
Errors
);
}
}
}
}
PSManagement.Api/PSManagement.Api.csproj
View file @
c6a1b9ab
...
...
@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="7.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
<PackageReference Include="MediatR" Version="
5.1.0
" />
<PackageReference Include="MediatR" Version="
8.0.1
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
...
...
PSManagement.Contracts/Customers/Responses/ContactInfoRecord.cs
0 → 100644
View file @
c6a1b9ab
using
System
;
namespace
PSManagement.Contracts.Customers.Responses
{
public
class
ContactInfoRecord
{
public
String
ContactType
{
get
;
set
;
}
public
String
ContactValue
{
get
;
set
;
}
}
}
PSManagement.Contracts/Customers/Responses/CustomerRecord.cs
0 → 100644
View file @
c6a1b9ab
using
PSManagement.Contracts.Customers.Requests
;
using
System
;
using
System.Collections.Generic
;
namespace
PSManagement.Contracts.Customers.Responses
{
public
class
CustomerRecord
{
public
CustomerRecord
()
{
}
public
int
Id
{
get
;
set
;
}
public
String
CustomerName
{
get
;
set
;
}
public
String
Email
{
get
;
set
;
}
public
AddressRecord
Address
{
get
;
set
;
}
public
IEnumerable
<
ContactInfoRecord
>
ContactInfo
{
get
;
set
;
}
}
}
PSManagement.Contracts/Customers/Responses/ListCustomersResponse.cs
0 → 100644
View file @
c6a1b9ab
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
PSManagement.Contracts.Customers.Responses
{
public
record
ListCustomersResponse
(
IEnumerable
<
CustomerRecord
>
Customers
);
}
PSManagement.Contracts/PSManagement.Contracts.csproj
View file @
c6a1b9ab
...
...
@@ -4,8 +4,4 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Customers\Responses\" />
</ItemGroup>
</Project>
PSManagement.Infrastructure.Persistence/AppDataContext/AppDbContext.cs
View file @
c6a1b9ab
using
Microsoft.EntityFrameworkCore
;
using
PSManagement.Domain.Customers.Aggregate
;
using
PSManagement.Domain.Departments.Aggregate
;
using
PSManagement.Domain.Employees.Aggregate
;
using
PSManagement.Domain.Identity.Aggregate
;
using
PSManagement.Domain.Projects.Aggregate
;
using
PSManagement.Domain.Steps.Aggregate
;
using
PSManagement.Domain.Steps.Entities
;
using
PSManagement.Domain.Tracking
;
using
PSManagement.Domain.Tracking.Entities
;
namespace
PSManagement.Infrastructure.Persistence
{
...
...
@@ -14,6 +21,19 @@ namespace PSManagement.Infrastructure.Persistence
public
DbSet
<
User
>
Users
{
get
;
set
;
}
public
DbSet
<
Customer
>
Customers
{
get
;
set
;
}
public
DbSet
<
Employee
>
Employees
{
get
;
set
;
}
public
DbSet
<
Department
>
Departments
{
get
;
set
;
}
public
DbSet
<
Project
>
Projects
{
get
;
set
;
}
public
DbSet
<
Step
>
Steps
{
get
;
set
;
}
public
DbSet
<
Item
>
Items
{
get
;
set
;
}
public
DbSet
<
Track
>
Tracks
{
get
;
set
;
}
public
DbSet
<
EmployeeTrack
>
EmployeeTraks
{
get
;
set
;
}
public
DbSet
<
StepTrack
>
StepTracks
{
get
;
set
;
}
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
...
...
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/EmployeeEntityConfiguration.cs
0 → 100644
View file @
c6a1b9ab
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
PSManagement.Domain.Employees.Aggregate
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public
class
EmployeeEntityConfiguration
:
IEntityTypeConfiguration
<
Employee
>
{
public
void
Configure
(
EntityTypeBuilder
<
Employee
>
builder
)
{
builder
.
OwnsOne
(
c
=>
c
.
Availability
,
p
=>
{
p
.
Property
(
e
=>
e
.
IsAvailable
).
HasColumnName
(
"IsAvailable"
);
p
.
Property
(
e
=>
e
.
WorkingHours
).
HasColumnName
(
"WorkingHours"
);
}
);
builder
.
OwnsOne
(
c
=>
c
.
PersonalInfo
,
p
=>
{
p
.
Property
(
e
=>
e
.
LastName
).
HasColumnName
(
"LastName"
);
p
.
Property
(
e
=>
e
.
FirstName
).
HasColumnName
(
"FirstName"
);
}
);
}
}
}
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/ItemEntityConfiguration.cs
0 → 100644
View file @
c6a1b9ab
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
PSManagement.Domain.Steps.Entities
;
namespace
PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public
class
ItemEntityConfiguration
:
IEntityTypeConfiguration
<
Item
>
{
public
void
Configure
(
EntityTypeBuilder
<
Item
>
builder
)
{
builder
.
OwnsOne
(
c
=>
c
.
Price
,
p
=>
{
p
.
Property
(
e
=>
e
.
Ammount
).
HasColumnName
(
"Ammount"
);
p
.
Property
(
e
=>
e
.
Currency
).
HasColumnName
(
"Currency"
);
}
);
}
}
}
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/ProjectEntityConfiguration.cs
0 → 100644
View file @
c6a1b9ab
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
PSManagement.Domain.Projects.Aggregate
;
namespace
PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public
class
ProjectEntityConfiguration
:
IEntityTypeConfiguration
<
Project
>
{
public
void
Configure
(
EntityTypeBuilder
<
Project
>
builder
)
{
builder
.
OwnsOne
(
c
=>
c
.
ProjectAggreement
,
p
=>
{
p
.
Property
(
e
=>
e
.
AggreementDate
).
HasColumnName
(
"AggreementDate"
);
p
.
Property
(
e
=>
e
.
AggreementNumber
).
HasColumnName
(
"AggreementNumber"
);
}
);
builder
.
OwnsOne
(
c
=>
c
.
ProjectInfo
,
p
=>
{
p
.
Property
(
e
=>
e
.
Description
).
HasColumnName
(
"Description"
);
p
.
Property
(
e
=>
e
.
Code
).
HasColumnName
(
"Code"
);
p
.
Property
(
e
=>
e
.
Name
).
HasColumnName
(
"Name"
);
}
);
builder
.
OwnsOne
(
c
=>
c
.
ProposalInfo
,
p
=>
{
p
.
Property
(
e
=>
e
.
ProposingBookDate
).
HasColumnName
(
"ProposingBookDate"
);
p
.
Property
(
e
=>
e
.
ProposingBookNumber
).
HasColumnName
(
"ProposingBookNumber"
);
}
);
}
}
}
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/StepEntityConfiguration.cs
0 → 100644
View file @
c6a1b9ab
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
PSManagement.Domain.Steps.Aggregate
;
namespace
PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public
class
StepEntityConfiguration
:
IEntityTypeConfiguration
<
Step
>
{
public
void
Configure
(
EntityTypeBuilder
<
Step
>
builder
)
{
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240731070622_addCustomer4.Designer.cs
0 → 100644
View file @
c6a1b9ab
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Metadata
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
PSManagement.Infrastructure.Persistence
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
[
DbContext
(
typeof
(
AppDbContext
))]
[
Migration
(
"20240731070622_addCustomer4"
)]
partial
class
addCustomer4
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Relational:Collation"
,
"Arabic_CI_AS"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
128
)
.
HasAnnotation
(
"ProductVersion"
,
"5.0.17"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Aggregate.Customer"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b
.
Property
<
string
>(
"CustomerName"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
string
>(
"Email"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Customers"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Identity.Aggregate.User"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b
.
Property
<
string
>(
"Email"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
string
>(
"FirstName"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
string
>(
"HashedPassword"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
Property
<
string
>(
"LastName"
)
.
HasColumnType
(
"nvarchar(max)"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Users"
);
});
modelBuilder
.
Entity
(
"PSManagement.Domain.Customers.Aggregate.Customer"
,
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
.
OwnsOne
(
"PSManagement.Domain.Customers.ValueObjects.Address"
,
"Address"
,
b1
=>
{
b1
.
Property
<
int
>(
"CustomerId"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
b1
.
Property
<
string
>(
"City"
)
.
HasColumnType
(
"nvarchar(max)"
)
.
HasColumnName
(
"City"
);
b1
.
Property
<
string
>(
"StreetName"
)
.
HasColumnType
(
"nvarchar(max)"
)
.
HasColumnName
(
"StreetName"
);
b1
.
Property
<
int
>(
"StreetNumber"
)
.
HasColumnType
(
"int"
)
.
HasColumnName
(
"StreetNumber"
);
b1
.
Property
<
int
>(
"ZipCode"
)
.
HasColumnType
(
"int"
)
.
HasColumnName
(
"ZipCode"
);
b1
.
HasKey
(
"CustomerId"
);
b1
.
ToTable
(
"Customers"
);
b1
.
WithOwner
()
.
HasForeignKey
(
"CustomerId"
);
});
b
.
Navigation
(
"Address"
);
b
.
Navigation
(
"ContactInfo"
);
});
#pragma warning restore 612, 618
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240731070622_addCustomer4.cs
0 → 100644
View file @
c6a1b9ab
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
addCustomer4
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
RenameColumn
(
name
:
"ConatctValue"
,
table
:
"ContactInfo"
,
newName
:
"ContactValue"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
RenameColumn
(
name
:
"ContactValue"
,
table
:
"ContactInfo"
,
newName
:
"ConatctValue"
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/20240801155515_AddDomains.Designer.cs
0 → 100644
View file @
c6a1b9ab
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240801155515_AddDomains.cs
0 → 100644
View file @
c6a1b9ab
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs
View file @
c6a1b9ab
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure/Services/Authentication/AuthenticationService.cs
View file @
c6a1b9ab
using
FluentResults
;
using
FluentResults
;
using
PSManagement.Application.Contracts.Authentication
;
using
PSManagement.Application.Contracts.Authorization
;
using
PSManagement.Domain.Customers.DomainErrors
;
using
PSManagement.Domain.Identity.Aggregate
;
using
PSManagement.Domain.Identity.DomainErrors
;
using
PSManagement.Domain.Identity.Repositories
;
//using PSManagement.SharedKernel.Utilities;
using
System
;
using
System.Threading.Tasks
;
...
...
@@ -25,7 +27,7 @@ namespace PSManagement.Infrastructure.Services.Authentication
User
u
=
await
_userRepository
.
GetByEmail
(
email
);
if
(
u
is
null
||
u
.
HashedPassword
!=
password
)
{
return
Result
.
Fail
<
AuthenticationResult
>(
new
InvalidLoginDataError
()
);
return
Result
.
Fail
<
AuthenticationResult
>(
UserErrors
.
InvalidLoginAttempt
);
}
String
token
=
_jwtTokenGenerator
.
GenerateToken
(
u
.
Id
,
u
.
FirstName
,
u
.
LastName
,
u
.
Email
);
...
...
@@ -41,7 +43,7 @@ namespace PSManagement.Infrastructure.Services.Authentication
// check if the user exist
var
u
=
await
_userRepository
.
GetByEmail
(
email
);
if
(
u
is
not
null
)
{
return
Result
.
Fail
<
AuthenticationResult
>(
new
AlreadyExistError
()
);
return
Result
.
Fail
(
UserErrors
.
AlreadyUserExist
);
}
var
user
=
await
_userRepository
.
AddAsync
(
new
User
{
...
...
PSManagement.SharedKernel/DomainErrors/
I
DomainError.cs
→
PSManagement.SharedKernel/DomainErrors/DomainError.cs
View file @
c6a1b9ab
...
...
@@ -7,8 +7,18 @@ using System.Threading.Tasks;
namespace
PSManagement.SharedKernel.DomainErrors
{
public
interface
IDomainError
:
I
Error
public
class
DomainError
:
Error
{
public
DomainError
(
string
message
)
:
base
(
message
)
{
}
public
DomainError
(
string
message
,
IError
causedBy
)
:
base
(
message
,
causedBy
)
{
}
protected
DomainError
()
{
}
}
}
PSManagement.SharedKernel/PSManagement.SharedKernel.csproj
View file @
c6a1b9ab
...
...
@@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="FluentResults" Version="3.16.0" />
<PackageReference Include="MediatR" Version="
5.1.0
" />
<PackageReference Include="MediatR" Version="
8.0.1
" />
</ItemGroup>
</Project>
PSManagement.SharedKernel/Utilities/Error.cs
View file @
c6a1b9ab
...
...
@@ -8,8 +8,8 @@ namespace PSManagement.SharedKernel.Utilities
{
public
record
Error
(
string
Code
,
string
Name
)
{
public
static
Error
None
=
new
(
string
.
Empty
,
string
.
Empty
);
public
static
readonly
Error
None
=
new
(
string
.
Empty
,
string
.
Empty
);
public
static
Error
NullValue
=
new
(
"Error.NullValue"
,
"Null value was provided"
);
public
static
readonly
Error
NullValue
=
new
(
"Error.NullValue"
,
"Null value was provided"
);
}
}
PSManagement.SharedKernel/Utilities/Result.cs
View file @
c6a1b9ab
...
...
@@ -27,7 +27,7 @@ namespace PSManagement.SharedKernel.Utilities
public
bool
IsSuccess
{
get
;
}
public
bool
IsFail
ure
=>
!
IsSuccess
;
public
bool
IsFail
=>
!
IsSuccess
;
public
Error
Error
{
get
;
}
...
...
PSManagement.SharedKernel/ValueObjects/Money.cs
0 → 100644
View file @
c6a1b9ab
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
PSManagement.SharedKernel.ValueObjects
{
public
record
Money
(
int
Ammount
,
String
Currency
);
}
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