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
069b3d66
Commit
069b3d66
authored
Aug 24, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add holiday, edit domain
parent
ef8c64f8
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1300 additions
and
46 deletions
+1300
-46
Holiday.cs
Clinics.Backend/Domain/Entities/Visits/Holiday.cs
+48
-0
Visit.cs
Clinics.Backend/Domain/Entities/Visits/Visit.cs
+16
-0
WaitingListRecord.cs
....Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
+1
-20
DomainErrors.cs
Clinics.Backend/Domain/Errors/DomainErrors.cs
+3
-0
HolidayConfiguration.cs
...Persistence/Configurations/Visits/HolidayConfiguration.cs
+16
-0
VisitConfiguration.cs
...d/Persistence/Configurations/Visits/VisitConfiguration.cs
+5
-0
WaitingListRecordConfiguration.cs
...figurations/WaitingList/WaitingListRecordConfiguration.cs
+0
-9
20240823234349_Add_Holiday.Designer.cs
...istence/Migrations/20240823234349_Add_Holiday.Designer.cs
+1086
-0
20240823234349_Add_Holiday.cs
...kend/Persistence/Migrations/20240823234349_Add_Holiday.cs
+89
-0
ClinicsDbContextModelSnapshot.cs
...d/Persistence/Migrations/ClinicsDbContextModelSnapshot.cs
+36
-17
No files found.
Clinics.Backend/Domain/Entities/Visits/Holiday.cs
0 → 100644
View file @
069b3d66
using
Domain.Errors
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits
;
public
sealed
class
Holiday
:
Entity
{
#
region
Private
ctor
private
Holiday
(
int
id
)
:
base
(
id
)
{
}
private
Holiday
(
int
id
,
int
visitId
,
DateOnly
from
,
int
duration
)
:
base
(
id
)
{
VisitId
=
visitId
;
From
=
from
;
Duration
=
duration
;
}
#
endregion
#
region
Properties
#
region
Visit
public
int
VisitId
{
get
;
private
set
;
}
#
endregion
public
DateOnly
From
{
get
;
private
set
;
}
public
int
Duration
{
get
;
private
set
;
}
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Result
<
Holiday
>
Create
(
int
visitId
,
DateOnly
from
,
int
duration
)
{
if
(
visitId
<=
0
||
duration
<=
0
)
return
Result
.
Failure
<
Holiday
>(
DomainErrors
.
InvalidValuesError
);
if
(
duration
>
5
)
return
Result
.
Failure
<
Holiday
>(
DomainErrors
.
InvalidHolidayDuration
);
return
new
Holiday
(
0
,
visitId
,
from
,
duration
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Visit.cs
View file @
069b3d66
...
...
@@ -83,6 +83,10 @@ public sealed class Visit : Entity
#
endregion
#
region
Holiday
public
Holiday
?
Holiday
{
get
;
private
set
;
}
#
endregion
#
endregion
#
region
Methods
...
...
@@ -166,5 +170,17 @@ public sealed class Visit : Entity
}
#
endregion
#
region
Add
holiday
public
Result
AddHoliday
(
DateOnly
from
,
int
duration
)
{
var
holidayResult
=
Holiday
.
Create
(
Id
,
from
,
duration
);
if
(
holidayResult
.
IsFailure
)
return
Result
.
Failure
(
holidayResult
.
Error
);
Holiday
=
holidayResult
.
Value
;
return
Result
.
Success
();
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
View file @
069b3d66
...
...
@@ -13,7 +13,6 @@ public sealed class WaitingListRecord : Entity
private
WaitingListRecord
(
int
id
,
int
patientId
)
:
base
(
id
)
{
PatientId
=
patientId
;
IsServed
=
false
;
}
#
endregion
...
...
@@ -27,16 +26,9 @@ public sealed class WaitingListRecord : Entity
#
endregion
#
region
Doctor
public
int
?
DoctorId
{
get
;
set
;
}
public
Doctor
?
Doctor
{
get
;
set
;
}
#
endregion
#
region
Additional
public
bool
IsServed
{
get
;
set
;
}
=
false
;
DateTime
ArrivalTime
{
get
;
set
;
}
#
endregion
...
...
@@ -55,16 +47,5 @@ public sealed class WaitingListRecord : Entity
#
endregion
#
region
Link
to
doctor
public
Result
LinkToDoctor
(
int
doctorId
)
{
if
(
doctorId
<=
0
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
DoctorId
=
doctorId
;
return
Result
.
Success
();
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Errors/DomainErrors.cs
View file @
069b3d66
...
...
@@ -37,4 +37,7 @@ public static class DomainErrors
public
static
Error
VisitAlreadyHasThisMedicalImage
=>
new
(
"Domain.PatientAlreadyHasThisMedicine"
,
"تحتوي هذه الزيارة بالفعل على الصورة التي تحاول اضافتها"
);
public
static
Error
InvalidHolidayDuration
=>
new
(
"Domain.InvalidHolidayDuration"
,
"الحد الأقصى للإجازة المرضية هو خمس أيام"
);
}
Clinics.Backend/Persistence/Configurations/Visits/HolidayConfiguration.cs
0 → 100644
View file @
069b3d66
using
Domain.Entities.Visits
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
namespace
Persistence.Configurations.Visits
;
public
class
HolidayConfiguration
:
IEntityTypeConfiguration
<
Holiday
>
{
public
void
Configure
(
EntityTypeBuilder
<
Holiday
>
builder
)
{
builder
.
ToTable
(
nameof
(
Holiday
));
builder
.
Property
(
holiday
=>
holiday
.
From
).
IsRequired
();
builder
.
Property
(
holiday
=>
holiday
.
Duration
).
IsRequired
();
}
}
Clinics.Backend/Persistence/Configurations/Visits/VisitConfiguration.cs
View file @
069b3d66
...
...
@@ -21,5 +21,10 @@ internal class VisitConfiguration : IEntityTypeConfiguration<Visit>
.
WithMany
()
.
HasForeignKey
(
visit
=>
visit
.
HospitalId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
builder
.
HasOne
(
visit
=>
visit
.
Holiday
)
.
WithOne
()
.
HasForeignKey
<
Holiday
>(
holiday
=>
holiday
.
VisitId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
}
}
\ No newline at end of file
Clinics.Backend/Persistence/Configurations/WaitingList/WaitingListRecordConfiguration.cs
View file @
069b3d66
...
...
@@ -10,18 +10,9 @@ internal class WaitingListRecordConfiguration : IEntityTypeConfiguration<Waiting
{
builder
.
ToTable
(
nameof
(
WaitingListRecord
));
builder
.
Property
(
waitingListRecord
=>
waitingListRecord
.
IsServed
)
.
HasDefaultValue
(
false
)
.
IsRequired
();
builder
.
HasOne
(
waitingListRecord
=>
waitingListRecord
.
Patient
)
.
WithMany
()
.
HasForeignKey
(
waitingListRecord
=>
waitingListRecord
.
PatientId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
builder
.
HasOne
(
waitingListRecord
=>
waitingListRecord
.
Doctor
)
.
WithMany
()
.
HasForeignKey
(
waitingListRecord
=>
waitingListRecord
.
DoctorId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
}
}
\ No newline at end of file
Clinics.Backend/Persistence/Migrations/20240823234349_Add_Holiday.Designer.cs
0 → 100644
View file @
069b3d66
This diff is collapsed.
Click to expand it.
Clinics.Backend/Persistence/Migrations/20240823234349_Add_Holiday.cs
0 → 100644
View file @
069b3d66
using
System
;
using
Microsoft.EntityFrameworkCore.Migrations
;
#
nullable
disable
namespace
Persistence.Migrations
{
/// <inheritdoc />
public
partial
class
Add_Holiday
:
Migration
{
/// <inheritdoc />
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_WaitingListRecord_Doctor_DoctorId"
,
table
:
"WaitingListRecord"
);
migrationBuilder
.
DropIndex
(
name
:
"IX_WaitingListRecord_DoctorId"
,
table
:
"WaitingListRecord"
);
migrationBuilder
.
DropColumn
(
name
:
"DoctorId"
,
table
:
"WaitingListRecord"
);
migrationBuilder
.
DropColumn
(
name
:
"IsServed"
,
table
:
"WaitingListRecord"
);
migrationBuilder
.
CreateTable
(
name
:
"Holiday"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
)
.
Annotation
(
"SqlServer:Identity"
,
"1, 1"
),
VisitId
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
From
=
table
.
Column
<
DateOnly
>(
type
:
"date"
,
nullable
:
false
),
Duration
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Holiday"
,
x
=>
x
.
Id
);
table
.
ForeignKey
(
name
:
"FK_Holiday_Visit_VisitId"
,
column
:
x
=>
x
.
VisitId
,
principalTable
:
"Visit"
,
principalColumn
:
"Id"
);
});
migrationBuilder
.
CreateIndex
(
name
:
"IX_Holiday_VisitId"
,
table
:
"Holiday"
,
column
:
"VisitId"
,
unique
:
true
);
}
/// <inheritdoc />
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"Holiday"
);
migrationBuilder
.
AddColumn
<
int
>(
name
:
"DoctorId"
,
table
:
"WaitingListRecord"
,
type
:
"int"
,
nullable
:
true
);
migrationBuilder
.
AddColumn
<
bool
>(
name
:
"IsServed"
,
table
:
"WaitingListRecord"
,
type
:
"bit"
,
nullable
:
false
,
defaultValue
:
false
);
migrationBuilder
.
CreateIndex
(
name
:
"IX_WaitingListRecord_DoctorId"
,
table
:
"WaitingListRecord"
,
column
:
"DoctorId"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_WaitingListRecord_Doctor_DoctorId"
,
table
:
"WaitingListRecord"
,
column
:
"DoctorId"
,
principalTable
:
"Doctor"
,
principalColumn
:
"Id"
);
}
}
}
Clinics.Backend/Persistence/Migrations/ClinicsDbContextModelSnapshot.cs
View file @
069b3d66
...
...
@@ -543,6 +543,31 @@ namespace Persistence.Migrations
b
.
ToTable
(
"PersonalInfo"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Holiday"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"int"
);
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
>(
"Duration"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
DateOnly
>(
"From"
)
.
HasColumnType
(
"date"
);
b
.
Property
<
int
>(
"VisitId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"VisitId"
)
.
IsUnique
();
b
.
ToTable
(
"Holiday"
,
(
string
)
null
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicalImages.VisitMedicalImage"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
...
...
@@ -670,21 +695,11 @@ namespace Persistence.Migrations
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
int
?>(
"DoctorId"
)
.
HasColumnType
(
"int"
);
b
.
Property
<
bool
>(
"IsServed"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"bit"
)
.
HasDefaultValue
(
false
);
b
.
Property
<
int
>(
"PatientId"
)
.
HasColumnType
(
"int"
);
b
.
HasKey
(
"Id"
);
b
.
HasIndex
(
"DoctorId"
);
b
.
HasIndex
(
"PatientId"
);
b
.
ToTable
(
"WaitingListRecord"
,
(
string
)
null
);
...
...
@@ -905,6 +920,15 @@ namespace Persistence.Migrations
b
.
Navigation
(
"Patient"
);
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Holiday"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Visits.Visit"
,
null
)
.
WithOne
(
"Holiday"
)
.
HasForeignKey
(
"Domain.Entities.Visits.Holiday"
,
"VisitId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
});
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Relations.VisitMedicalImages.VisitMedicalImage"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.Medicals.MedicalImages.MedicalImage"
,
"MedicalImage"
)
...
...
@@ -990,19 +1014,12 @@ namespace Persistence.Migrations
modelBuilder
.
Entity
(
"Domain.Entities.WaitingList.WaitingListRecord"
,
b
=>
{
b
.
HasOne
(
"Domain.Entities.People.Doctors.Doctor"
,
"Doctor"
)
.
WithMany
()
.
HasForeignKey
(
"DoctorId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
b
.
HasOne
(
"Domain.Entities.People.Patients.Patient"
,
"Patient"
)
.
WithMany
()
.
HasForeignKey
(
"PatientId"
)
.
OnDelete
(
DeleteBehavior
.
NoAction
)
.
IsRequired
();
b
.
Navigation
(
"Doctor"
);
b
.
Navigation
(
"Patient"
);
});
...
...
@@ -1052,6 +1069,8 @@ namespace Persistence.Migrations
modelBuilder
.
Entity
(
"Domain.Entities.Visits.Visit"
,
b
=>
{
b
.
Navigation
(
"Holiday"
);
b
.
Navigation
(
"MedicalImages"
);
b
.
Navigation
(
"MedicalTests"
);
...
...
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