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
356661c5
Commit
356661c5
authored
Jun 22, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update ingredient service
parent
cbdb40d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
6 deletions
+9
-6
IIngredientService.cs
ApplicationCore/Interfaces/IServices/IIngredientService.cs
+1
-1
IngredientService.cs
...ationCore/Services/IngredientService/IngredientService.cs
+8
-5
ApplicationCore.csproj.AssemblyReference.cache
...bug/net5.0/ApplicationCore.csproj.AssemblyReference.cache
+0
-0
No files found.
ApplicationCore/Interfaces/IServices/IIngredientService.cs
View file @
356661c5
...
@@ -10,7 +10,7 @@ namespace ApplicationCore.Interfaces.IServices
...
@@ -10,7 +10,7 @@ namespace ApplicationCore.Interfaces.IServices
{
{
public
interface
IIngredientService
:
IService
<
IngredientModel
>
public
interface
IIngredientService
:
IService
<
IngredientModel
>
{
{
public
void
AddToMedicine
(
MedicineIngredientModel
medicineIngredientModel
);
public
Task
<
MedicineIngredientModel
>
AddToMedicine
(
MedicineIngredientModel
medicineIngredientModel
);
public
void
RemoveFromMedicine
(
MedicineIngredientModel
medicineIngredientModel
);
public
void
RemoveFromMedicine
(
MedicineIngredientModel
medicineIngredientModel
);
}
}
...
...
ApplicationCore/Services/IngredientService/IngredientService.cs
View file @
356661c5
...
@@ -24,7 +24,7 @@ namespace ApplicationCore.Services
...
@@ -24,7 +24,7 @@ namespace ApplicationCore.Services
}
}
public
async
void
AddToMedicine
(
MedicineIngredientModel
medicineIngredientModel
)
{
public
async
Task
<
MedicineIngredientModel
>
AddToMedicine
(
MedicineIngredientModel
medicineIngredientModel
)
{
var
medicine
=
await
_unitOfWork
.
Entity
.
GetById
(
medicineIngredientModel
.
IngredientId
,
_specification
);
var
medicine
=
await
_unitOfWork
.
Entity
.
GetById
(
medicineIngredientModel
.
IngredientId
,
_specification
);
MedicineIngredient
medicineIngredient
=
_mapper
.
Map
<
MedicineIngredient
>(
medicineIngredientModel
);
MedicineIngredient
medicineIngredient
=
_mapper
.
Map
<
MedicineIngredient
>(
medicineIngredientModel
);
medicine
.
MedicineIngredients
.
Add
(
medicine
.
MedicineIngredients
.
Add
(
...
@@ -32,14 +32,17 @@ namespace ApplicationCore.Services
...
@@ -32,14 +32,17 @@ namespace ApplicationCore.Services
);
);
_unitOfWork
.
Entity
.
Update
(
medicine
);
_unitOfWork
.
Entity
.
Update
(
medicine
);
_unitOfWork
.
Commit
();
_unitOfWork
.
Commit
();
return
medicineIngredientModel
;
}
}
public
async
void
RemoveFromMedicine
(
MedicineIngredientModel
medicineIngredientModel
)
public
async
void
RemoveFromMedicine
(
MedicineIngredientModel
medicineIngredientModel
)
{
{
var
medicine
=
await
_unitOfWork
.
Entity
.
GetById
(
medicineIngredientModel
.
IngredientId
,
_specification
);
var
ingredient
=
await
_unitOfWork
.
Ingredients
.
GetById
(
medicineIngredientModel
.
IngredientId
,
_specification
);
MedicineIngredient
medicineIngredient
=
_mapper
.
Map
<
MedicineIngredient
>(
medicineIngredientModel
);
MedicineIngredient
medicineIngredient
=
_mapper
.
Map
<
MedicineIngredient
>(
medicineIngredientModel
);
var
m
=
medicine
.
MedicineIngredients
.
Where
(
p
=>
p
.
IngredientId
==
medicineIngredientModel
.
IngredientId
).
FirstOrDefault
();
var
m
=
ingredient
.
MedicineIngredients
.
Where
(
p
=>
p
.
MedicineId
==
medicineIngredientModel
.
MedicineId
).
FirstOrDefault
();
medicine
.
MedicineIngredients
.
Remove
(
m
);
ingredient
.
MedicineIngredients
.
Remove
(
m
);
_unitOfWork
.
Entity
.
Update
(
medicine
);
_unitOfWork
.
Entity
.
Update
(
ingredient
);
_unitOfWork
.
Commit
();
_unitOfWork
.
Commit
();
}
}
...
...
ApplicationCore/obj/Debug/net5.0/ApplicationCore.csproj.AssemblyReference.cache
View file @
356661c5
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