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
ae1c806f
Commit
ae1c806f
authored
Jun 19, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implements the new repositories
parent
4a4eeb53
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
199 additions
and
3 deletions
+199
-3
SeedDataContext.cs
Infrastructure/Data/SeedDataContext.cs
+151
-2
UnitOfWork.cs
Infrastructure/UnitOfWork/UnitOfWork.cs
+48
-1
Infrastructure.csproj.AssemblyReference.cache
...ebug/net5.0/Infrastructure.csproj.AssemblyReference.cache
+0
-0
Infrastructure.dll
Infrastructure/obj/Debug/net5.0/Infrastructure.dll
+0
-0
Infrastructure.pdb
Infrastructure/obj/Debug/net5.0/Infrastructure.pdb
+0
-0
No files found.
Infrastructure/Data/SeedDataContext.cs
View file @
ae1c806f
using
System
;
using
ApplicationDomain.Entities
;
using
Microsoft.AspNetCore.Identity
;
using
Microsoft.EntityFrameworkCore
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -6,7 +9,153 @@ using System.Threading.Tasks;
namespace
Infrastructure.Data
{
class
SeedDataContext
public
class
SeedDataContext
{
public
static
ModelBuilder
Seed
(
ModelBuilder
modelBuilder
)
{
#
region
Roles
modelBuilder
.
Entity
<
IdentityRole
>().
HasData
(
new
IdentityRole
{
Name
=
"Admin"
,
NormalizedName
=
"Admin"
,
Id
=
"1-2-1"
},
new
IdentityRole
{
Name
=
"patient"
,
NormalizedName
=
"patient"
,
Id
=
"1"
}
);
modelBuilder
.
Entity
<
IdentityUserRole
<
String
>>()
.
HasData
(
new
IdentityUserRole
<
String
>
{
UserId
=
"1"
,
RoleId
=
"1-2-1"
},
new
IdentityUserRole
<
String
>
{
UserId
=
"2"
,
RoleId
=
"1"
}
);
#
endregion
Roles
#
region
User
var
ph
=
new
PasswordHasher
<
IdentityUser
>();
var
admin
=
new
User
{
Id
=
"1"
,
FirstName
=
"Hasan"
,
LastName
=
"Kh"
,
Avatar
=
"avatar.jpg"
,
Email
=
"hasan@b"
,
UserName
=
"Hasan.Bahjat"
,
PasswordHash
=
ph
.
HashPassword
(
null
,
"123@Aa"
),
NormalizedEmail
=
"hasan@b"
,
NormalizedUserName
=
"Hasan.Bahjat"
,
CreationTime
=
DateTime
.
Now
};
var
PatientAccount
=
new
User
{
Id
=
"2"
,
FirstName
=
"Hasan"
,
LastName
=
"Khaddour"
,
Avatar
=
"avatar1.jpg"
,
Email
=
"hasan.bahjat@mail.y"
,
PasswordHash
=
ph
.
HashPassword
(
null
,
"123@Aa"
),
UserName
=
"Hasan.Khaddour"
,
NormalizedEmail
=
"hasan@b"
,
NormalizedUserName
=
"Hasan.khaddour"
,
CreationTime
=
DateTime
.
Now
};
modelBuilder
.
Entity
<
User
>()
.
HasData
(
admin
,
PatientAccount
);
#
endregion
User
#
region
Patients
var
Patient
=
new
Patient
{
Id
=
1
,
BIO
=
"a Patient "
,
UserId
=
PatientAccount
.
Id
,
};
modelBuilder
.
Entity
<
Patient
>().
HasData
(
Patient
);
#
endregion
Patients
#
region
Categories
var
c1
=
new
Category
{
Id
=
1
,
Name
=
"Antibiotic"
};
var
c2
=
new
Category
{
Id
=
2
,
Name
=
"Painkiller"
};
modelBuilder
.
Entity
<
Category
>().
HasData
(
c1
,
c2
);
#
endregion
Categories
#
region
MedicineType
modelBuilder
.
Entity
<
MedicineType
>().
HasData
(
new
MedicineType
{
Id
=
1
,
TypeName
=
"Tablet"
},
new
MedicineType
{
Id
=
2
,
TypeName
=
"Syrup"
}
);
#
endregion
MedicineType
#
region
Ingredients
modelBuilder
.
Entity
<
Ingredient
>().
HasData
(
new
Ingredient
{
Id
=
1
,
Name
=
"Amoxicillin"
},
new
Ingredient
{
Id
=
2
,
Name
=
"Paracetamol"
}
);
#
endregion
Ingredients
#
region
Medicines
var
med
=
new
Medicine
{
Id
=
1
,
ScintificName
=
"Augmentine"
,
TradeName
=
"Augmentine"
,
Description
=
"antibitic mdicine"
,
ManufactureName
=
"Ibin Sina"
,
SideEffect
=
"No. "
,
//Category=c1 ,
Image
=
"med1.png"
,
Dosage
=
12
,
Price
=
2500
,
};
// modelBuilder.Entity<MedicineIngredient>().HasData(
// new MedicineIngredient { Id = 1, MedicineId = 1, IngredientId = 1 },
// new MedicineIngredient { Id = 2, MedicineId = 2, IngredientId = 2 }
//);
modelBuilder
.
Entity
<
Medicine
>().
HasData
(
med
);
#
endregion
Medicines
#
region
MedicalState
var
st
=
new
MedicalState
{
Id
=
1
,
PatientId
=
1
,
PrescriptionTime
=
DateTime
.
Now
,
};
modelBuilder
.
Entity
<
MedicalState
>().
HasData
(
st
);
#
endregion
MedicalState
return
modelBuilder
;
}
}
}
Infrastructure/UnitOfWork/UnitOfWork.cs
View file @
ae1c806f
...
...
@@ -16,6 +16,13 @@ namespace Infrastructure.UnitOfWork
{
private
readonly
DbContext
_context
;
private
IGenericRepository
<
T
>
_entity
;
private
IIngredientRepository
_ingredients
;
private
IMedicalStateRepository
_medicalStates
;
private
IPatientRepository
_patients
;
private
IMedicineRepository
_medicines
;
public
UnitOfWork
(
DbContext
context
)
{
_context
=
context
;
...
...
@@ -30,15 +37,55 @@ namespace Infrastructure.UnitOfWork
return
_entity
??
(
_entity
=
new
GenericRepository
<
T
>(
_context
));
}
}
public
IIngredientRepository
Ingredients
{
get
{
return
_ingredients
??
(
_ingredients
=
new
IngredientRepository
(
_context
));
}
}
void
IUnitOfWork
<
T
>.
Save
()
public
IMedicalStateRepository
MedicalStates
{
get
{
return
_medicalStates
??
(
_medicalStates
=
new
MedicalStateRepository
(
_context
));
}
}
public
IPatientRepository
Patients
{
get
{
return
_patients
??
(
_patients
=
new
PatientRepository
(
_context
));
}
}
public
IMedicineRepository
Medicines
{
get
{
return
_medicines
??
(
_medicines
=
new
MedicineRepository
(
_context
));
}
}
public
void
Commit
()
{
_context
.
SaveChanges
();
}
public
void
RollBack
()
{
}
}
}
Infrastructure/obj/Debug/net5.0/Infrastructure.csproj.AssemblyReference.cache
View file @
ae1c806f
No preview for this file type
Infrastructure/obj/Debug/net5.0/Infrastructure.dll
View file @
ae1c806f
No preview for this file type
Infrastructure/obj/Debug/net5.0/Infrastructure.pdb
View file @
ae1c806f
No preview for this file type
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