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
b295eec4
Commit
b295eec4
authored
Jul 26, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
a74dc97e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
8 deletions
+75
-8
AuthenticationController.cs
...pi/Controllers/Authentication/AuthenticationController.cs
+2
-2
CustomersController.cs
...nagement.Api/Controllers/Customers/CustomersController.cs
+38
-0
PSManagement.Api.csproj
PSManagement.Api/PSManagement.Api.csproj
+9
-0
launchSettings.json
PSManagement.Api/Properties/launchSettings.json
+1
-1
Startup.cs
PSManagement.Api/Startup.cs
+21
-5
appsettings.json
PSManagement.Api/appsettings.json
+4
-0
No files found.
PSManagement.Api/Controllers/Authentication/AuthenticationController.cs
View file @
b295eec4
...
...
@@ -20,7 +20,7 @@ namespace PSManagement.Api.Controllers.Authentication
[
HttpPost
(
"Login"
)]
public
async
Task
<
IActionResult
>
Login
([
FromBody
]
LoginRequest
loginRequest
)
{
Result
<
AuthenticationResult
>
result
=
await
_authenticationService
.
Login
(
loginRequest
.
Email
,
loginRequest
.
PassWor
r
d
);
Result
<
AuthenticationResult
>
result
=
await
_authenticationService
.
Login
(
loginRequest
.
Email
,
loginRequest
.
PassWord
);
if
(
result
.
IsSuccess
)
{
AuthenticationResponse
response
=
new
(
...
...
@@ -32,7 +32,7 @@ namespace PSManagement.Api.Controllers.Authentication
return
Ok
(
response
);
}
return
Problem
(
title
:
result
.
Reasons
[
0
].
Message
,
detail
:
result
.
Error
s
[
0
].
Message
,
statusCode
:
400
);
return
Problem
(
title
:
result
.
Errors
[
0
].
Message
,
detail
:
result
.
Errors
[
0
].
Reason
s
[
0
].
Message
,
statusCode
:
400
);
}
[
HttpPost
(
"Register"
)]
public
async
Task
<
IActionResult
>
Register
([
FromBody
]
RegisterRequest
registerRequest
)
...
...
PSManagement.Api/Controllers/Customers/CustomersController.cs
0 → 100644
View file @
b295eec4
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
MediatR
;
using
PSManagement.Contracts.Customers.Requests
;
using
PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
;
using
PSManagement.Domain.Customers.ValueObjects
;
namespace
PSManagement.Api.Controllers.Customers
{
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
Authorize
]
public
class
CustomersController
:
ControllerBase
{
private
readonly
ISender
_sender
;
public
CustomersController
(
ISender
sender
)
{
_sender
=
sender
;
}
[
HttpPost
]
public
async
Task
<
IActionResult
>
CreateCustomer
(
Guid
userId
,
Guid
subscriptionId
,
CreateCustomerRequest
request
)
{
Address
address
=
new
Address
(
request
.
City
,
request
.
StreetName
,
request
.
ZipCode
,
request
.
StreetNumber
);
var
command
=
new
CreateCustomerCommand
(
request
.
CustomerName
,
address
);
var
result
=
await
_sender
.
Send
(
command
);
return
result
;
}
}
}
PSManagement.Api/PSManagement.Api.csproj
View file @
b295eec4
...
...
@@ -5,13 +5,22 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="5.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PSManagement.Application\PSManagement.Application.csproj" />
<ProjectReference Include="..\PSManagement.Contracts\PSManagement.Contracts.csproj" />
<ProjectReference Include="..\PSManagement.Domain\PSManagement.Domain.csproj" />
<ProjectReference Include="..\PSManagement.Infrastructure.Persistence\PSManagement.Infrastructure.Persistence.csproj" />
<ProjectReference Include="..\PSManagement.Infrastructure\PSManagement.Infrastructure.csproj" />
<ProjectReference Include="..\PSManagement.Presentation\PSManagement.Presentation.csproj" />
<ProjectReference Include="..\PSManagement.SharedKernel\PSManagement.SharedKernel.csproj" />
</ItemGroup>
</Project>
PSManagement.Api/Properties/launchSettings.json
View file @
b295eec4
...
...
@@ -19,7 +19,7 @@
},
"PSManagement.Api"
:
{
"commandName"
:
"Project"
,
"dotnetRunMessages"
:
"true"
,
"dotnetRunMessages"
:
true
,
"launchBrowser"
:
true
,
"launchUrl"
:
"swagger"
,
"applicationUrl"
:
"https://localhost:5001;http://localhost:5000"
,
...
...
PSManagement.Api/Startup.cs
View file @
b295eec4
...
...
@@ -13,6 +13,7 @@ using System;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
PSManagement.Infrastructure.Persistence.DI
;
namespace
PSManagement.Api
{
...
...
@@ -28,12 +29,27 @@ namespace PSManagement.Api
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
{
// adding dependency injection
services
.
AddPresentation
();
services
.
AddApplication
();
services
.
AddInfrastructure
(
Configuration
);
services
.
AddPresentation
()
.
AddApplication
()
.
AddInfrastructure
(
Configuration
)
.
AddPersistence
(
Configuration
);
services
.
AddControllers
();
services
.
AddCors
(
options
=>
{
options
.
AddPolicy
(
"AllowFrontend"
,
builder
=>
builder
.
WithOrigins
(
"http://localhost:4200"
)
// Add your frontend URL here
.
AllowAnyHeader
()
.
AllowAnyMethod
()
.
AllowCredentials
());
});
services
.
AddSwaggerGen
(
options
=>
{
options
.
SwaggerDoc
(
"v1"
,
new
OpenApiInfo
{
Title
=
"PSManagement.Api"
,
Version
=
"v1"
});
...
...
@@ -75,7 +91,7 @@ namespace PSManagement.Api
app
.
UseHttpsRedirection
();
app
.
UseRouting
();
app
.
UseCors
(
"AllowFrontend"
);
app
.
UseAuthentication
();
app
.
UseAuthorization
();
app
.
UseEndpoints
(
endpoints
=>
...
...
PSManagement.Api/appsettings.json
View file @
b295eec4
...
...
@@ -12,5 +12,9 @@
"ExpireMinutes"
:
60
,
"Issuer"
:
"HIAST-PS-Management-Server"
,
"Audience"
:
"All"
},
"ConnectionStrings"
:
{
"DefaultConnection"
:
"Data Source=.
\\
sqlexpress;Initial Catalog=PSManagement ;Integrated Security=True"
}
}
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