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)
{
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)
{
var t = GetCurrentUser();
dto.User.UserName = t.UserName;
dto.User.CreationTime = t.CreationTime;
dto.User.Email = t.Email;
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);
......
......@@ -54,9 +54,9 @@ 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>
......
......@@ -123,16 +123,19 @@
<section style="background-color: #f4f5f7;">
<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 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">
......@@ -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