Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HIAST-Clinics
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
almohanad.hafez
HIAST-Clinics
Commits
018a268f
Commit
018a268f
authored
Aug 26, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Seed medicines
parent
91d82271
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
130 additions
and
1 deletion
+130
-1
Program.cs
Clinics.Backend/API/Program.cs
+1
-0
SeedMedicinesHelper.cs
...ics.Backend/API/SeedDatabaseHelper/SeedMedicinesHelper.cs
+16
-0
Medicine.cs
...cs.Backend/Domain/Entities/Medicals/Medicines/Medicine.cs
+1
-1
ISeedMedicines.cs
...kend/Persistence/SeedDatabase/Medicines/ISeedMedicines.cs
+6
-0
SeedMedicines.cs
...ckend/Persistence/SeedDatabase/Medicines/SeedMedicines.cs
+106
-0
No files found.
Clinics.Backend/API/Program.cs
View file @
018a268f
...
@@ -127,6 +127,7 @@ var app = builder.Build();
...
@@ -127,6 +127,7 @@ var app = builder.Build();
#region Seed database
#region Seed database
await
SeedHelper
.
Seed
(
app
);
await
SeedHelper
.
Seed
(
app
);
await
SeedAdminUserHelper
.
Seed
(
app
);
await
SeedAdminUserHelper
.
Seed
(
app
);
await
SeedMedicinesHelper
.
Seed
(
app
);
#endregion
#endregion
// Configure the HTTP request pipeline.
// Configure the HTTP request pipeline.
...
...
Clinics.Backend/API/SeedDatabaseHelper/SeedMedicinesHelper.cs
0 → 100644
View file @
018a268f
using
Persistence.SeedDatabase.AdminUser
;
using
Persistence.SeedDatabase.Medicines
;
namespace
API.SeedDatabaseHelper
;
public
class
SeedMedicinesHelper
{
public
static
async
Task
Seed
(
IApplicationBuilder
applicationBuilder
)
{
using
(
var
serviceScope
=
applicationBuilder
.
ApplicationServices
.
CreateScope
())
{
var
seedMedicines
=
serviceScope
.
ServiceProvider
.
GetRequiredService
<
ISeedMedicines
>();
await
seedMedicines
.
Seed
();
}
}
}
Clinics.Backend/Domain/Entities/Medicals/Medicines/Medicine.cs
View file @
018a268f
...
@@ -12,7 +12,7 @@ public sealed class Medicine : Entity
...
@@ -12,7 +12,7 @@ public sealed class Medicine : Entity
private
Medicine
(
int
id
)
:
base
(
id
)
{
}
private
Medicine
(
int
id
)
:
base
(
id
)
{
}
p
rivate
Medicine
(
int
id
,
MedicineForm
medicineForm
,
int
amount
,
string
name
,
decimal
dosage
)
:
base
(
id
)
p
ublic
Medicine
(
int
id
,
MedicineForm
medicineForm
,
int
amount
,
string
name
,
decimal
dosage
)
:
base
(
id
)
{
{
MedicineForm
=
medicineForm
;
MedicineForm
=
medicineForm
;
Amount
=
amount
;
Amount
=
amount
;
...
...
Clinics.Backend/Persistence/SeedDatabase/Medicines/ISeedMedicines.cs
0 → 100644
View file @
018a268f
namespace
Persistence.SeedDatabase.Medicines
;
public
interface
ISeedMedicines
{
public
Task
Seed
();
}
Clinics.Backend/Persistence/SeedDatabase/Medicines/SeedMedicines.cs
0 → 100644
View file @
018a268f
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
using
Microsoft.EntityFrameworkCore
;
using
Persistence.Context
;
namespace
Persistence.SeedDatabase.Medicines
;
public
class
SeedMedicines
:
ISeedMedicines
{
#
region
Ctor
DI
private
readonly
ClinicsDbContext
_clinicsContext
;
public
SeedMedicines
(
ClinicsDbContext
clinicsContext
)
{
_clinicsContext
=
clinicsContext
;
}
#
endregion
private
readonly
MedicineForm
Tablet
=
Domain
.
Entities
.
Medicals
.
Medicines
.
MedicineFormValues
.
MedicineForms
.
Tablet
;
private
readonly
MedicineForm
Syrup
=
Domain
.
Entities
.
Medicals
.
Medicines
.
MedicineFormValues
.
MedicineForms
.
Syrup
;
public
async
Task
Seed
()
{
var
currentSize
=
(
await
(
_clinicsContext
.
Set
<
Medicine
>().
ToListAsync
())).
Count
;
if
(
currentSize
==
0
)
{
List
<
Medicine
>
medicines
=
new
();
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Cetamol"
,
500
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Cetamol"
,
500
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Paracetamol"
,
325
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Cough Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Ibuprofen"
,
200
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Aspirin"
,
100
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Children's Cough Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Amoxicillin"
,
500
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Azithromycin"
,
250
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Antibiotic Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Metformin"
,
500
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Atorvastatin"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Cough and Cold Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Omeprazole"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Ranitidine"
,
150
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Antacid Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Levofloxacin"
,
500
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Ciprofloxacin"
,
250
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Antibiotic Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Doxycycline"
,
100
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Tetracycline"
,
250
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Antibiotic Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Prednisone"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Hydrocortisone"
,
10
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Steroid Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Lisinopril"
,
10
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Enalapril"
,
5
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Blood Pressure Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Simvastatin"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Atorvastatin"
,
10
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Cholesterol Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Albuterol"
,
2
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Ipratropium"
,
2
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Asthma Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Rabeprazole"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Omeprazole"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Antacid Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Citalopram"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Fluoxetine"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Antidepressant Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Amlodipine"
,
5
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Lisinopril"
,
10
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Blood Pressure Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Metoprolol"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Propranolol"
,
20
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Heart Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Warfarin"
,
5
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Aspirin"
,
100
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Blood Thinner Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Furosemide"
,
40
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Hydrochlorothiazide"
,
25
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Diuretic Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Spironolactone"
,
25
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Triamterene"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Diuretic Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Allopurinol"
,
100
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Colchicine"
,
6
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Gout Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Glipizide"
,
5
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Metformin"
,
500
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Diabetes Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Lorazepam"
,
1
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Alprazolam"
,
5
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Anxiety Syrup"
,
50
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
20
,
"Zolpidem"
,
5
));
medicines
.
Add
(
new
Medicine
(
0
,
Tablet
,
10
,
"Eszopiclone"
,
2
));
medicines
.
Add
(
new
Medicine
(
0
,
Syrup
,
100
,
"Sleep Syrup"
,
50
));
foreach
(
var
medicine
in
medicines
)
{
_clinicsContext
.
Entry
(
medicine
.
MedicineForm
).
State
=
EntityState
.
Unchanged
;
_clinicsContext
.
Set
<
Medicine
>().
Add
(
medicine
);
}
await
_clinicsContext
.
SaveChangesAsync
();
}
}
}
\ No newline at end of file
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