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
8de31697
Commit
8de31697
authored
May 27, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ingredient controller
parent
dabd6158
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
0 deletions
+161
-0
IngredientController.cs
WebPresentation/Controllers/IngredientController.cs
+161
-0
No files found.
WebPresentation/Controllers/IngredientController.cs
0 → 100644
View file @
8de31697
using
ApplicationCore.Entities
;
using
ApplicationCore.Interfaces
;
using
ApplicationCore.Services.IngredientService
;
using
ApplicationCore.Services.MedicineService
;
using
ApplicationCore.Services.PatientService
;
using
Microsoft.AspNetCore.Identity
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.EntityFrameworkCore
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
WebPresentation.Controllers
{
public
class
IngredientController
:
BaseController
{
private
readonly
IngredientService
_ingredientService
;
private
readonly
MedicineService
_medicineService
;
public
IngredientController
(
UserManager
<
User
>
userManager
,
IUnitOfWork
<
Medicine
>
medicineUnitOfWork
,
IUnitOfWork
<
Ingredient
>
ingredientUnitOfWork
)
:
base
(
userManager
)
{
_ingredientService
=
new
IngredientService
(
ingredientUnitOfWork
);
_medicineService
=
new
MedicineService
(
medicineUnitOfWork
);
}
public
IActionResult
Index
()
{
var
s
=
_ingredientService
.
GetAllIngredients
();
return
View
(
s
);
}
public
IActionResult
Details
(
int
?
id
)
{
if
(
id
==
null
)
{
return
NotFound
();
}
var
ingredient
=
_ingredientService
.
GetIngredientDetails
((
int
)
id
);
if
(
ingredient
==
null
)
{
return
NotFound
();
}
return
View
(
ingredient
);
}
// GET: Projects/Create
public
IActionResult
Create
()
{
return
View
();
}
// POST: Projects/Create
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[
HttpPost
]
[
ValidateAntiForgeryToken
]
public
IActionResult
Create
(
Ingredient
ingredient
,
int
id
)
{
if
(
ModelState
.
IsValid
)
{
_ingredientService
.
AddIngredient
(
ingredient
);
return
RedirectToAction
(
nameof
(
Index
));
}
return
View
(
ingredient
);
}
// GET: Projects/Edit/5
public
IActionResult
Edit
(
int
?
id
)
{
if
(
id
==
null
)
{
return
NotFound
();
}
var
ingredient
=
_ingredientService
.
GetIngredientDetails
((
int
)
id
);
if
(
ingredient
==
null
)
{
return
NotFound
();
}
return
View
(
ingredient
);
}
// POST: Projects/Edit/5
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[
HttpPost
]
[
ValidateAntiForgeryToken
]
public
IActionResult
Edit
(
int
id
,
Ingredient
ingredient
)
{
if
(
id
!=
ingredient
.
Id
)
{
return
NotFound
();
}
if
(
ModelState
.
IsValid
)
{
try
{
_ingredientService
.
Update
(
ingredient
);
}
catch
(
DbUpdateConcurrencyException
)
{
/*
if (!_medicineService.projectExists(project.Id))
{
return NotFound();
}
else
{
throw;
}
*/
}
return
RedirectToAction
(
nameof
(
Index
));
}
return
View
(
ingredient
);
}
// GET: Projects/Delete/5
public
IActionResult
Delete
(
int
id
)
{
var
ingredient
=
_ingredientService
.
GetIngredientDetails
(
id
);
if
(
ingredient
==
null
)
{
return
NotFound
();
}
return
View
(
ingredient
);
}
public
IActionResult
AddIngredints
(
int
id
)
{
var
s
=
_ingredientService
.
GetAllIngredients
();
ViewBag
.
MedicineId
=
id
;
return
View
(
s
);
}
// POST: Projects/Delete/5
[
HttpPost
,
ActionName
(
"Delete"
)]
[
ValidateAntiForgeryToken
]
public
IActionResult
DeleteConfirmed
(
int
id
)
{
_ingredientService
.
Delete
(
id
);
return
RedirectToAction
(
nameof
(
Index
));
}
}
}
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