Commit d57cc8df authored by hasan khaddour's avatar hasan khaddour

final

parent a98768ba
......@@ -101,7 +101,7 @@ namespace WebPresentation.Controllers
}
[HttpPost, ActionName("Delete")]
public async Task<IActionResult> DeleteConfirmed(int id)
public virtual async Task<IActionResult> DeleteConfirmed(int id)
{
TDto DetailDto = await _service.GetDetails(id);
......
......@@ -59,7 +59,7 @@ namespace WebPresentation.Controllers
[HttpPost]
[ValidateAntiForgeryToken]
[ImageLoadFilter]
public IActionResult Edit(int id, [FromForm] PatientViewModel viewModel)
public async Task<IActionResult> Edit(int id, [FromForm] PatientViewModel viewModel)
{
if (id != viewModel.Id)
{
......@@ -73,26 +73,33 @@ namespace WebPresentation.Controllers
{
dto = _mapper.Map<PatientDTO>(viewModel);
dto.User.Avatar= viewModel.ImageName;
dto = _patientService.Update(dto);
var user = await _userManager.FindByIdAsync(dto.UserId);
if (user != null)
{
var t = GetCurrentUser();
dto.User.UserName = t.UserName;
dto.User.CreationTime = t.CreationTime;
dto.User.Email = t.Email;
user.Avatar = viewModel.ImageName != "" ? viewModel.ImageName : dto.User.Avatar;
user.PhoneNumber = dto.User.PhoneNumber;
user.LastName = dto.User.LastName;
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);
//var r =await _userManager.UpdateAsync(dto.User);
// if (!r.Succeeded) {
// return View(viewModel);
// }
}
catch (DbUpdateConcurrencyException)
{
return View("Error");
}
return RedirectToAction("Details", new { id = dto.Id });
return RedirectToAction("Details", new { id = viewModel.Id });
}
return View(viewModel);
......
......@@ -53,10 +53,10 @@ namespace WebPresentation.Controllers
var n= ((IMedicalStateService)_service)
.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
......
......@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using WebPresentation.ViewModel.Identity;
using WebPresentation.ViewModels;
......@@ -59,6 +60,20 @@ namespace WebPresentation.Controllers
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
services.AddDbContext<MedicDbContext>(
options => {
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
});
# endregion ADD DB Context
......
......@@ -48,18 +48,11 @@
margin-bottom: 1rem;
}
.form-control {
border: 1px solid #596280;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
font-size: .825rem;
}
</style>
<section class="page-section ">
<form asp-action="Edit" enctype="multipart/form-data">
<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="card h-100">
<div class="card-body">
......@@ -130,7 +123,18 @@
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
<div class="text-right">
<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>
......
......@@ -52,50 +52,50 @@
<hr class="mt-0 ">
<div class="row p-4">
<div class="table-responsive">
<table id="Ingredients_" class="table table-bordered table-hover">
<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)
{
<table id="Ingredients_" class="table table-bordered table-hover">
<thead class="thead-light">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<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>
<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>
<hr />
......@@ -121,18 +121,21 @@
</section>
<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="col-12 col-lg-10 mb-4 mb-lg-0">
<div class="card mb-3" style="border-radius: .5rem;">
<div id="medicines-table">
<div class="col">
<div class="row g-0">
<div class="row d-flex justify-content-center align-items-center h-100">
<div id="medicines-table">
<!-- Medicines table will be dynamically loaded here -->
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<div id="item-container">
<div class="modal fade" id="item" tabindex="-1" aria-labelledby="label-" role="dialog"
aria-hidden="true">
......@@ -215,7 +218,7 @@
</tr>
</thead >
<tbody id="${tableName + "b"}">
<tbody id="${tableName + "b"}">
</tbody>
</table>`;
......@@ -333,7 +336,7 @@
updateMedicines();
showToast(result.result, result.message);
showToast(result.message, result.result);
} else {
console.error('Error:', response.statusText);
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