Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Medic
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
Medic
Commits
56f4426e
Commit
56f4426e
authored
Jun 22, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update api
parent
b4cba512
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
26 deletions
+62
-26
AccessController.cs
API/Controllers/Access/AccessController.cs
+9
-9
BaseController.cs
API/Controllers/Base/BaseController.cs
+6
-2
CrudController.cs
API/Controllers/CRUD/CrudController.cs
+6
-5
MedicalStateController.cs
API/Controllers/MedicalStateController.cs
+6
-7
MedicineController.cs
API/Controllers/MedicineController.cs
+3
-3
ExceptionHandler.cs
API/Midlewares/Exception Handler/ExceptionHandler.cs
+32
-0
No files found.
API/Controllers/Access/Access
API
Controller.cs
→
API/Controllers/Access/AccessController.cs
View file @
56f4426e
...
@@ -8,18 +8,18 @@ using Microsoft.AspNetCore.Mvc;
...
@@ -8,18 +8,18 @@ using Microsoft.AspNetCore.Mvc;
using
System
;
using
System
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
WebPresentation
.Controllers
namespace
API
.Controllers
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
ApiController
]
[
AllowAnonymous
]
[
AllowAnonymous
]
public
class
Access
API
Controller
:
BaseController
public
class
AccessController
:
BaseController
{
{
private
readonly
SignInManager
<
User
>
_signInManager
;
private
readonly
SignInManager
<
User
>
_signInManager
;
private
readonly
IPatientService
_patientSerivce
;
private
readonly
IPatientService
_patientSerivce
;
public
Access
API
Controller
(
UserManager
<
User
>
userManager
,
public
AccessController
(
UserManager
<
User
>
userManager
,
SignInManager
<
User
>
signInManager
,
SignInManager
<
User
>
signInManager
,
IPatientService
patientService
):
base
(
userManager
)
IPatientService
patientService
):
base
(
userManager
)
{
{
...
@@ -97,17 +97,17 @@ namespace WebPresentation.Controllers
...
@@ -97,17 +97,17 @@ namespace WebPresentation.Controllers
}
}
[
HttpGet
(
"log"
)]
public
IActionResult
i
()
{
return
Ok
(
new
{
message
=
"Logout successful"
});
}
[
HttpPost
(
"logout"
)]
[
HttpPost
(
"logout"
)]
public
async
Task
<
IActionResult
>
Logout
()
public
async
Task
<
IActionResult
>
Logout
()
{
{
await
_signInManager
.
SignOutAsync
();
await
_signInManager
.
SignOutAsync
();
return
Ok
(
new
{
message
=
"Logout successful"
});
return
Ok
(
new
{
message
=
"Logout successful"
});
}
}
}
[
HttpGet
(
"log"
)]
public
IActionResult
Log
()
{
return
Ok
(
new
{
message
=
"log successful"
});
}
}
}
}
\ No newline at end of file
API/Controllers/Base/BaseController.cs
View file @
56f4426e
...
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
...
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
namespace
WebPresentation
.Controllers
namespace
API
.Controllers
{
{
[
Authorize
]
[
Authorize
]
[
ApiController
]
[
ApiController
]
...
@@ -30,7 +30,11 @@ namespace WebPresentation.Controllers
...
@@ -30,7 +30,11 @@ namespace WebPresentation.Controllers
protected
String
GetUserName
()
{
protected
String
GetUserName
()
{
return
GetCurrentUser
().
UserName
;
return
GetCurrentUser
().
UserName
;
}
}
protected
String
GetUserEmail
()
{
return
GetCurrentUser
().
Email
;
}
protected
String
GetUserId
()
{
protected
String
GetUserId
()
{
return
GetCurrentUser
().
Id
;
return
GetCurrentUser
().
Id
;
...
...
API/Controllers/
Base/CrudAPI
Controller.cs
→
API/Controllers/
CRUD/Crud
Controller.cs
View file @
56f4426e
...
@@ -6,15 +6,15 @@ using Microsoft.AspNetCore.Mvc;
...
@@ -6,15 +6,15 @@ using Microsoft.AspNetCore.Mvc;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
WebPresentation
.Controllers
namespace
API
.Controllers
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
ApiController
]
public
class
Crud
API
Controller
<
TModel
>
:
BaseController
where
TModel
:
DomainBase
public
class
CrudController
<
TModel
>
:
BaseController
where
TModel
:
DomainBase
{
{
protected
readonly
IService
<
TModel
>
_service
;
protected
readonly
IService
<
TModel
>
_service
;
public
Crud
API
Controller
(
public
CrudController
(
IService
<
TModel
>
service
,
IService
<
TModel
>
service
,
UserManager
<
User
>
userManager
)
UserManager
<
User
>
userManager
)
...
@@ -23,6 +23,7 @@ namespace WebPresentation.Controllers
...
@@ -23,6 +23,7 @@ namespace WebPresentation.Controllers
_service
=
service
;
_service
=
service
;
}
}
[
HttpGet
]
public
async
virtual
Task
<
IActionResult
>
GetAll
()
public
async
virtual
Task
<
IActionResult
>
GetAll
()
{
{
IEnumerable
<
TModel
>
models
=
await
_service
.
GetAll
();
IEnumerable
<
TModel
>
models
=
await
_service
.
GetAll
();
...
@@ -49,7 +50,7 @@ namespace WebPresentation.Controllers
...
@@ -49,7 +50,7 @@ namespace WebPresentation.Controllers
return
Ok
(
ModifiedModel
);
return
Ok
(
ModifiedModel
);
}
}
[
Http
Put
(
"delete
"
)]
[
Http
Delete
(
"{id}
"
)]
public
IActionResult
Delete
(
int
id
)
public
IActionResult
Delete
(
int
id
)
{
{
...
@@ -58,7 +59,7 @@ namespace WebPresentation.Controllers
...
@@ -58,7 +59,7 @@ namespace WebPresentation.Controllers
return
Ok
(
new
{
mesage
=
"deleted"
});
return
Ok
(
new
{
mesage
=
"deleted"
});
}
}
[
HttpP
ost
(
"create"
)
]
[
HttpP
ut
]
public
IActionResult
Create
(
TModel
model
)
public
IActionResult
Create
(
TModel
model
)
{
{
...
...
API/Controllers/MedicalState
Api
Controller.cs
→
API/Controllers/MedicalStateController.cs
View file @
56f4426e
...
@@ -10,16 +10,16 @@ using System.Collections.Generic;
...
@@ -10,16 +10,16 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
WebPresentation
.Controllers
namespace
API
.Controllers
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
ApiController
]
[
AllowAnonymous
]
[
AllowAnonymous
]
public
class
MedicalState
ApiController
:
CrudAPI
Controller
<
MedicalStateModel
>
public
class
MedicalState
Controller
:
Crud
Controller
<
MedicalStateModel
>
{
{
private
readonly
IPatientService
_patientService
;
private
readonly
IPatientService
_patientService
;
public
MedicalState
Api
Controller
(
public
MedicalStateController
(
IMedicalStateService
medicalstateService
,
IMedicalStateService
medicalstateService
,
IPatientService
patientService
,
IPatientService
patientService
,
UserManager
<
User
>
userManager
)
UserManager
<
User
>
userManager
)
...
@@ -30,10 +30,9 @@ namespace WebPresentation.Controllers
...
@@ -30,10 +30,9 @@ namespace WebPresentation.Controllers
public
override
async
Task
<
IActionResult
>
GetAll
()
public
override
async
Task
<
IActionResult
>
GetAll
()
{
{
string
u
=
GetUserId
();
var
ps
=
await
_patientService
.
GetByUserEmail
(
GetUserEmail
());
var
ps
=
await
_patientService
.
GetAll
();
var
pId
=
ps
.
Id
;
var
pId
=
ps
.
Where
(
p
=>
p
.
User
.
Id
==
u
).
FirstOrDefault
().
Id
;
var
meds
=
await
((
IMedicalStateService
)
_service
).
GetAllPatientMedicalStates
(
pId
);
var
meds
=
((
IMedicalStateService
)
_service
).
GetAllPatientMedicalStates
(
pId
);
return
Ok
(
meds
);
return
Ok
(
meds
);
}
}
...
...
API/Controllers/Medicine
API
Controller.cs
→
API/Controllers/MedicineController.cs
View file @
56f4426e
...
@@ -9,13 +9,13 @@ using System.Collections.Generic;
...
@@ -9,13 +9,13 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
WebPresentation
.Controllers
namespace
API
.Controllers
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
ApiController
]
public
class
Medicine
APIController
:
CrudAPI
Controller
<
MedicineModel
>
public
class
Medicine
Controller
:
Crud
Controller
<
MedicineModel
>
{
{
public
Medicine
API
Controller
(
public
MedicineController
(
IMedicineService
medicalstateService
,
IMedicineService
medicalstateService
,
UserManager
<
User
>
userManager
)
UserManager
<
User
>
userManager
)
:
base
(
medicalstateService
,
userManager
)
:
base
(
medicalstateService
,
userManager
)
...
...
API/Midlewares/Exception Handler/ExceptionHandler.cs
0 → 100644
View file @
56f4426e
using
Microsoft.AspNetCore.Http
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Threading.Tasks
;
namespace
API.Midlewares
{
public
class
ExceptionHandler
{
private
readonly
RequestDelegate
_next
;
public
ExceptionHandler
(
RequestDelegate
next
)
{
_next
=
next
;
}
public
async
Task
InvokeAsync
(
HttpContext
httpContext
)
{
try
{
await
_next
(
httpContext
);
}
catch
(
Exception
ex
)
{
}
}
}
}
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