Commit d57cc8df authored by hasan khaddour's avatar hasan khaddour

final

parent a98768ba
...@@ -101,7 +101,7 @@ namespace WebPresentation.Controllers ...@@ -101,7 +101,7 @@ namespace WebPresentation.Controllers
} }
[HttpPost, ActionName("Delete")] [HttpPost, ActionName("Delete")]
public async Task<IActionResult> DeleteConfirmed(int id) public virtual async Task<IActionResult> DeleteConfirmed(int id)
{ {
TDto DetailDto = await _service.GetDetails(id); TDto DetailDto = await _service.GetDetails(id);
......
...@@ -59,7 +59,7 @@ namespace WebPresentation.Controllers ...@@ -59,7 +59,7 @@ namespace WebPresentation.Controllers
[HttpPost] [HttpPost]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
[ImageLoadFilter] [ImageLoadFilter]
public IActionResult Edit(int id, [FromForm] PatientViewModel viewModel) public async Task<IActionResult> Edit(int id, [FromForm] PatientViewModel viewModel)
{ {
if (id != viewModel.Id) if (id != viewModel.Id)
{ {
...@@ -73,26 +73,33 @@ namespace WebPresentation.Controllers ...@@ -73,26 +73,33 @@ namespace WebPresentation.Controllers
{ {
dto = _mapper.Map<PatientDTO>(viewModel); dto = _mapper.Map<PatientDTO>(viewModel);
dto.User.Avatar= viewModel.ImageName;
dto = _patientService.Update(dto); dto = _patientService.Update(dto);
var user = await _userManager.FindByIdAsync(dto.UserId);
if (user != null)
{ {
var t = GetCurrentUser(); user.Avatar = viewModel.ImageName != "" ? viewModel.ImageName : dto.User.Avatar;
dto.User.UserName = t.UserName; user.PhoneNumber = dto.User.PhoneNumber;
dto.User.CreationTime = t.CreationTime; user.LastName = dto.User.LastName;
dto.User.Email = t.Email; user.FirstName = dto.User.FirstName;
var result = await _userManager.UpdateAsync(user);
if (!result.Succeeded)
{
return View(viewModel);
}
} }
//dto.User.Avatar= viewModel.ImageName != "" ? viewModel.ImageName :dto.User.Avatar;
//dto.User.Patient = _mapper.Map<Patient>(dto); //dto.User.Patient = _mapper.Map<Patient>(dto);
//var r =await _userManager.UpdateAsync(dto.User);
// if (!r.Succeeded) {
// return View(viewModel);
// }
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
return View("Error"); return View("Error");
} }
return RedirectToAction("Details", new { id = dto.Id }); return RedirectToAction("Details", new { id = viewModel.Id });
} }
return View(viewModel); return View(viewModel);
......
...@@ -53,10 +53,10 @@ namespace WebPresentation.Controllers ...@@ -53,10 +53,10 @@ namespace WebPresentation.Controllers
var n= ((IMedicalStateService)_service) var n= ((IMedicalStateService)_service)
.AddToPateint(patientId, _mapper.Map<MedicalStateDTO>(medicalState)); .AddToPateint(patientId, _mapper.Map<MedicalStateDTO>(medicalState));
return RedirectToAction("Details", "MedicalState" , new { Id =n.Id }); return Json(new { success = true, redirectUrl = Url.Action("Details", new { id = medicalState.Id }) });
} }
return View(medicalState); return PartialView(medicalState);
} }
#region json #region json
......
...@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization; ...@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using System.Threading.Tasks;
using WebPresentation.ViewModel.Identity; using WebPresentation.ViewModel.Identity;
using WebPresentation.ViewModels; using WebPresentation.ViewModels;
...@@ -59,6 +60,20 @@ namespace WebPresentation.Controllers ...@@ -59,6 +60,20 @@ namespace WebPresentation.Controllers
return View(Input); return View(Input);
} }
public override async Task<IActionResult> DeleteConfirmed(int id)
{
PatientDTO DetailDto = await _service.GetDetails(id);
if (DetailDto == null || !criteria(DetailDto))
{
return PartialView("PartialNotFound");
}
var r =await _userManager.DeleteAsync(DetailDto.User);
_service.Delete(id);
return RedirectToAction("Index");
}
} }
} }
...@@ -45,6 +45,7 @@ namespace WebPresentation ...@@ -45,6 +45,7 @@ namespace WebPresentation
services.AddDbContext<MedicDbContext>( services.AddDbContext<MedicDbContext>(
options => { options => {
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
}); });
# endregion ADD DB Context # endregion ADD DB Context
......
...@@ -48,18 +48,11 @@ ...@@ -48,18 +48,11 @@
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.form-control {
border: 1px solid #596280;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
font-size: .825rem;
}
</style> </style>
<section class="page-section "> <section class="page-section ">
<form asp-action="Edit" enctype="multipart/form-data"> <form asp-action="Edit" enctype="multipart/form-data">
<div class="container"> <div class="container">
<div asp-validation-summary="ModelOnly" class="row gutters border-1"> <div class="row gutters border-1">
<div class="col-xl-3 col-lg-3 col-md-12 col-sm-12 col-12"> <div class="col-xl-3 col-lg-3 col-md-12 col-sm-12 col-12">
<div class="card h-100"> <div class="card h-100">
<div class="card-body"> <div class="card-body">
...@@ -130,7 +123,18 @@ ...@@ -130,7 +123,18 @@
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12"> <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
<div class="text-right"> <div class="text-right">
<a type="button" asp-action="Index" asp-controller="Home" class="btn btn-secondary">Cancel</a> <a type="button" asp-action="Index" asp-controller="Home" class="btn btn-secondary">Cancel</a>
<button type="button" id="submit" name="submit" class="btn btn-primary">Update</button> <input type="hidden" asp-for="Id" />
<input type="hidden" asp-for="User.Id" />
<input type="hidden" asp-for="UserId" />
<input type="hidden" asp-for="User.CreationTime" />
<input type="hidden" asp-for="User.ConcurrencyStamp" />
<input type="hidden" asp-for="User.PasswordHash" />
<input type="hidden" asp-for="User.UserName" />
<input type="hidden" asp-for="User.Avatar" />
<button type="submit" class="btn btn-primary">Save</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -52,50 +52,50 @@ ...@@ -52,50 +52,50 @@
<hr class="mt-0 "> <hr class="mt-0 ">
<div class="row p-4"> <div class="row p-4">
<div class="table-responsive"> <div class="table-responsive">
<table id="Ingredients_" class="table table-bordered table-hover"> <table id="Ingredients_" class="table table-bordered table-hover">
<thead class="thead-light"> <thead class="thead-light">
<tr>
<th>#</th>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Dosage</th>
<th>Manufacture Name</th>
<th>Manage</th>
</tr>
</thead>
<tbody id="cc">
@if (Model.Medicines.Count == 0)
{
<tr> <tr>
<td></td> <th>#</th>
<td></td> <th>Name</th>
<td></td> <th>Description</th>
<td></td> <th>Price</th>
<td></td> <th>Dosage</th>
<td></td> <th>Manufacture Name</th>
<td></td> <th>Manage</th>
</tr> </tr>
</thead>
<tbody id="cc">
@if (Model.Medicines.Count == 0)
{
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
}
@foreach (var ing in Model.Medicines)
{
<tr>
<td>@(a+=1)</td>
<td>@ing.TradeName</td>
<td>@ing.Description</td>
<td>@ing.Price.ToString("C")</td>
<td>@ing.Dosage</td>
<td>@ing.ManufactureName</td>
<td>
<button class="btn btn-danger btn-sm" ondblclick='DeleteConfirm("Delete Confirm", "Are you sure you want to delete @ing.TradeName from this medical case?", @ing.Id)'>Delete</button>
<button class="btn btn-info btn-sm" onclick="DetailMedicine(@ing.Id)">Details</button>
</td>
</tr>
}
</tbody>
</table>
}
@foreach (var ing in Model.Medicines)
{
<tr>
<td>@(a+=1)</td>
<td>@ing.TradeName</td>
<td>@ing.Description</td>
<td>@ing.Price.ToString("C")</td>
<td>@ing.Dosage</td>
<td>@ing.ManufactureName</td>
<td>
<button class="btn btn-danger btn-sm" ondblclick='DeleteConfirm("Delete Confirm", "Are you sure you want to delete @ing.TradeName from this medical case?", @ing.Id)'>Delete</button>
<button class="btn btn-info btn-sm" onclick="DetailMedicine(@ing.Id)">Details</button>
</td>
</tr>
}
</tbody>
</table>
</div> </div>
</div> </div>
<hr /> <hr />
...@@ -121,18 +121,21 @@ ...@@ -121,18 +121,21 @@
</section> </section>
<section style="background-color: #f4f5f7;"> <section style="background-color: #f4f5f7;">
<div class="container h-100"> <div class="container h-100">
<div class="row d-flex justify-content-center align-items-center h-100"> <div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-12 col-lg-10 mb-4 mb-lg-0"> <div class="col">
<div class="card mb-3" style="border-radius: .5rem;"> <div class="row g-0">
<div class="row d-flex justify-content-center align-items-center h-100">
<div id="medicines-table"> <div id="medicines-table">
<!-- Medicines table will be dynamically loaded here -->
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<div id="item-container"> <div id="item-container">
<div class="modal fade" id="item" tabindex="-1" aria-labelledby="label-" role="dialog" <div class="modal fade" id="item" tabindex="-1" aria-labelledby="label-" role="dialog"
aria-hidden="true"> aria-hidden="true">
...@@ -215,7 +218,7 @@ ...@@ -215,7 +218,7 @@
</tr> </tr>
</thead > </thead >
<tbody id="${tableName + "b"}"> <tbody id="${tableName + "b"}">
</tbody> </tbody>
</table>`; </table>`;
...@@ -333,7 +336,7 @@ ...@@ -333,7 +336,7 @@
updateMedicines(); updateMedicines();
showToast(result.result, result.message); showToast(result.message, result.result);
} else { } else {
console.error('Error:', response.statusText); console.error('Error:', response.statusText);
showToast('Failed to remove medicine', 'Error'); showToast('Failed to remove medicine', 'Error');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment