Commit 143feeb8 authored by hasan khaddour's avatar hasan khaddour

Merge branch 'uploadImageFeature'

parents 6fb551c9 718bee1e
...@@ -40,8 +40,8 @@ namespace ApplicationCore.Mapper ...@@ -40,8 +40,8 @@ namespace ApplicationCore.Mapper
.ForMember(s=>s.MedicalStateMedicines , op=>op.Ignore()) .ForMember(s=>s.MedicalStateMedicines , op=>op.Ignore())
.ForMember(s => s.Patient, op => op.Ignore()); .ForMember(s => s.Patient, op => op.Ignore());
CreateMap<Category, Category>(); CreateMap<Category, CategoryDTO>();
CreateMap<Category, Category>() CreateMap<CategoryDTO, Category>()
.ForMember(dest => dest.Medicines, opt => opt.Ignore()) .ForMember(dest => dest.Medicines, opt => opt.Ignore())
; ;
CreateMap<MedicineType, MedicineTypeDTO>().ReverseMap(); CreateMap<MedicineType, MedicineTypeDTO>().ReverseMap();
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -9,7 +10,6 @@ namespace ApplicationDomain.Entities ...@@ -9,7 +10,6 @@ namespace ApplicationDomain.Entities
public class Patient : EntityBase public class Patient : EntityBase
{ {
public String UserId { get; set; } public String UserId { get; set; }
public User User { get; set; } public User User { get; set; }
public String BIO { get; set; } public String BIO { get; set; }
......
...@@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Identity; ...@@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using WebPresentation.Filters.ImageLoad;
using AutoMapper;
namespace WebPresentation.Controllers namespace WebPresentation.Controllers
{ {
...@@ -12,13 +14,15 @@ namespace WebPresentation.Controllers ...@@ -12,13 +14,15 @@ namespace WebPresentation.Controllers
public class AccessController : Controller public class AccessController : Controller
{ {
private readonly IMapper _mapper;
private readonly UserManager<User> _userManager; private readonly UserManager<User> _userManager;
private readonly SignInManager<User> _signInManager; private readonly SignInManager<User> _signInManager;
public AccessController(SignInManager<User> signInManager, public AccessController(SignInManager<User> signInManager,
UserManager<User> userManager) UserManager<User> userManager,
IMapper mapper )
{ {
_mapper = mapper;
_userManager = userManager; _userManager = userManager;
_signInManager = signInManager; _signInManager = signInManager;
} }
...@@ -68,6 +72,7 @@ namespace WebPresentation.Controllers ...@@ -68,6 +72,7 @@ namespace WebPresentation.Controllers
return View(); return View();
} }
[HttpPost] [HttpPost]
[ImageLoadFilter]
public async Task<IActionResult> Register(RegisterationInputModel Input) public async Task<IActionResult> Register(RegisterationInputModel Input)
{ {
Input.ReturnUrl ??= Url.Content("/Home/Index"); Input.ReturnUrl ??= Url.Content("/Home/Index");
...@@ -75,14 +80,15 @@ namespace WebPresentation.Controllers ...@@ -75,14 +80,15 @@ namespace WebPresentation.Controllers
ViewBag.ReturUrl = Input.ReturnUrl; ViewBag.ReturUrl = Input.ReturnUrl;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var patient = _mapper.Map<Patient>(Input.Patient);
var user = new User { var user = new User {
NormalizedEmail = Input.Email, NormalizedEmail = Input.Email,
FirstName=Input.FirstName, FirstName=Input.FirstName,
LastName=Input.LastName, LastName=Input.LastName,
Avatar=Input.Avatar, Avatar=Input.ImageName,
UserName = Input.Email, UserName = Input.Email,
Email = Input.Email, Email = Input.Email,
Patient = Input.Patient, Patient = patient,
CreationTime = DateTime.Now, CreationTime = DateTime.Now,
}; };
......
...@@ -9,7 +9,11 @@ using System; ...@@ -9,7 +9,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using WebPresentation.Filters.ImageLoad;
using WebPresentation.Filters.ModelStateValidation; using WebPresentation.Filters.ModelStateValidation;
using WebPresentation.Services;
using WebPresentation.ViewModels;
namespace WebPresentation.Controllers namespace WebPresentation.Controllers
{ {
public class CRUDController<TDto,TVModel> : BaseController where TDto : DTOBase where TVModel : ViewModels.BaseViewModel public class CRUDController<TDto,TVModel> : BaseController where TDto : DTOBase where TVModel : ViewModels.BaseViewModel
...@@ -129,19 +133,20 @@ namespace WebPresentation.Controllers ...@@ -129,19 +133,20 @@ namespace WebPresentation.Controllers
[HttpPost] [HttpPost]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
[StateValidationFilter] [ImageLoadFilter]
public IActionResult Edit(int id, TVModel viewModel) public IActionResult Edit(int id, [FromForm] TVModel viewModel)
{ {
if (id != viewModel.Id) if (id != viewModel.Id)
{ {
return NotFound(); return NotFound();
} }
TDto dto = null; TDto dto ;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
try try
{ {
dto = _mapper.Map<TDto>(viewModel); dto = _mapper.Map<TDto>(viewModel);
dto = _service.Update(dto); dto = _service.Update(dto);
......
...@@ -10,6 +10,8 @@ using ApplicationCore.DTOs; ...@@ -10,6 +10,8 @@ using ApplicationCore.DTOs;
using AutoMapper; using AutoMapper;
using WebPresentation.ViewModels; using WebPresentation.ViewModels;
using System.Threading.Tasks; using System.Threading.Tasks;
using WebPresentation.Filters.ImageLoad;
using Microsoft.EntityFrameworkCore;
namespace WebPresentation.Controllers namespace WebPresentation.Controllers
{ {
...@@ -45,14 +47,47 @@ namespace WebPresentation.Controllers ...@@ -45,14 +47,47 @@ namespace WebPresentation.Controllers
return View(t); return View(t);
} }
[Authorize(Roles = "patient")] [Authorize(Roles = "patient")]
public async Task<IActionResult> Edit(int id)
public async Task<IActionResult> Edit()
{ {
var t = await getCurrentPatient(); var t = await getCurrentPatient();
if (id != t.Id) {
return View("Error");
}
return View(t); return View(t);
} }
[HttpPost]
[ValidateAntiForgeryToken]
[ImageLoadFilter]
public IActionResult Edit(int id, [FromForm] PatientViewModel viewModel)
{
if (id != viewModel.Id)
{
return NotFound();
}
PatientDTO dto;
if (ModelState.IsValid)
{
try
{
dto = _mapper.Map<PatientDTO>(viewModel);
dto.User.Avatar= viewModel.ImageName;
dto = _patientService.Update(dto);
}
catch (DbUpdateConcurrencyException)
{
return View("Error");
}
return RedirectToAction("Details", new { id = dto.Id });
}
return View(viewModel);
}
[Authorize(Roles = "patient")] [Authorize(Roles = "patient")]
public async Task<IActionResult> Details(int? id ) { public async Task<IActionResult> Details(int? id ) {
var t = await getCurrentPatient(); var t = await getCurrentPatient();
......
...@@ -43,7 +43,7 @@ namespace WebPresentation.Controllers ...@@ -43,7 +43,7 @@ namespace WebPresentation.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var uId = GetUserId(); var uId = GetUserId();
var p = _patientService.GetByUserId(uId).Id; var p = _patientService.GetByUserId(uId).Result.Id;
if (medicalState.PrescriptionTime == DateTime.MinValue ) if (medicalState.PrescriptionTime == DateTime.MinValue )
medicalState.PrescriptionTime = DateTime.Now; medicalState.PrescriptionTime = DateTime.Now;
var n= ((IMedicalStateService)_service).AddToPateint(p,_mapper.Map<MedicalStateDTO>(medicalState)); var n= ((IMedicalStateService)_service).AddToPateint(p,_mapper.Map<MedicalStateDTO>(medicalState));
......
...@@ -32,20 +32,21 @@ namespace WebPresentation.Controllers ...@@ -32,20 +32,21 @@ namespace WebPresentation.Controllers
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var user = new User var patient = _mapper.Map<Patient>(Input.Patient);
{ var user = new User
NormalizedEmail = Input.Email, {
FirstName = Input.FirstName, NormalizedEmail = Input.Email,
LastName = Input.LastName, FirstName = Input.FirstName,
Avatar = Input.Avatar, LastName = Input.LastName,
UserName = Input.Email, Avatar = Input.ImageName,
Email = Input.Email, UserName = Input.Email,
Patient = Input.Patient, Email = Input.Email,
CreationTime = DateTime.Now, Patient = patient,
CreationTime = DateTime.Now,
};
};
var result =_userManager.CreateAsync(user, Input.Password).Result;
var result =_userManager.CreateAsync(user, Input.Password).Result;
if (result.Succeeded) { if (result.Succeeded) {
return RedirectToAction("Index", "Patients"); return RedirectToAction("Index", "Patients");
......
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebPresentation.Services;
using WebPresentation.ViewModels;
namespace WebPresentation.Filters.ImageLoad
{
public class ImageLoadFilter :ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext context)
{
var imageUploaded = context.ActionArguments.Values.Where(p => p is IImageForm).FirstOrDefault();
var imageService = context.HttpContext.RequestServices.GetService(typeof(IImageService));
if(
(((IImageForm)imageUploaded).ImageFile != null )
&&
(((IImageForm)imageUploaded).ImageFile.Length != 0)){
var imagePath = ((IImageService)imageService).SaveImageAsync(((IImageForm)imageUploaded).ImageFile,context.Controller.GetType().Name).Result;
((IImageForm)imageUploaded).ImageName = imagePath; // You can pass other information as needed
}
}
}
}
...@@ -16,6 +16,7 @@ namespace WebPresentation.Filters.ModelStateValidation ...@@ -16,6 +16,7 @@ namespace WebPresentation.Filters.ModelStateValidation
if (!context.ModelState.IsValid) if (!context.ModelState.IsValid)
{ {
Controller controller = context.Controller as Controller; Controller controller = context.Controller as Controller;
if (controller != null) if (controller != null)
{ {
var model = context.ActionArguments.Values.Where(p=> p is not int ).FirstOrDefault(); var model = context.ActionArguments.Values.Where(p=> p is not int ).FirstOrDefault();
......
...@@ -9,9 +9,27 @@ namespace ApplicationCore.Mappere ...@@ -9,9 +9,27 @@ namespace ApplicationCore.Mappere
{ {
public ViewModelObjectMapper() public ViewModelObjectMapper()
{ {
CreateMap<MedicineViewModel, MedicineDTO>().ReverseMap(); CreateMap<MedicineViewModel, MedicineDTO>()
CreateMap<PatientDTO, PatientViewModel>().ReverseMap(); .ForMember(dest => dest.Image, opt => opt.MapFrom(src => src.ImageName)) // Map ImageName from MedicineViewModel to Image in MedicineDTO
.ForMember(dest => dest.Ingredients, opt => opt.MapFrom(src => src.Ingredients))
.ForMember(dest => dest.Category, opt => opt.MapFrom(src => src.Category))
.ForMember(dest => dest.Dosage, opt => opt.MapFrom(src => src.Dosage))
.ForMember(dest => dest.MedicineType, opt => opt.MapFrom(src => src.MedicineType))
.ForMember(dest => dest.MedicineIngredients, opt => opt.MapFrom(src => src.MedicineIngredients));
CreateMap<MedicineDTO, MedicineViewModel>()
.ForMember(dest => dest.ImageName, opt => opt.MapFrom(src => src.Image))
.ForMember(dest => dest.Ingredients, opt => opt.MapFrom(src => src.Ingredients))
.ForMember(dest => dest.MedicineIngredients, opt => opt.MapFrom(src => src.MedicineIngredients));
CreateMap<PatientViewModel, PatientDTO>();
CreateMap<PatientDTO, PatientViewModel>()
.ForMember(dest => dest.ImageName, opt => opt.MapFrom(src => src.User.Avatar))
.ForMember(dest => dest.ImageFile, opt => opt.Ignore());
;
CreateMap<IngredientViewModel, IngredientDTO>().ReverseMap(); CreateMap<IngredientViewModel, IngredientDTO>().ReverseMap();
CreateMap<MedicineIngredientDTO, MedicineIngredientViewModel>().ReverseMap(); CreateMap<MedicineIngredientDTO, MedicineIngredientViewModel>().ReverseMap();
......
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace WebPresentation.Services
{
public interface IImageService
{
Task<string> SaveImageAsync(IFormFile file, String folderName);
}
public class ImageService : IImageService
{
private readonly string _uploadsFolderPath;
private readonly String _rootPath;
public ImageService(IWebHostEnvironment env)
{
_uploadsFolderPath = Path.Combine(env.WebRootPath, "img");
_rootPath = env.WebRootPath;
}
public async Task<string> SaveImageAsync(IFormFile file,String folderName)
{
var uploadsFolderPath = Path.Combine(_uploadsFolderPath, folderName);
var uniqueFileName = Guid.NewGuid().ToString() + "_" + file.FileName;
var filePath = Path.Combine(uploadsFolderPath, uniqueFileName);
if (file.Length > 0)
{
Directory.CreateDirectory(uploadsFolderPath);
using (var stream = new FileStream(filePath, FileMode.Create))
{
await file.CopyToAsync(stream);
}
}
return folderName +"/"+uniqueFileName; // Return relative path
}
}
}
...@@ -21,6 +21,7 @@ using System; ...@@ -21,6 +21,7 @@ using System;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using ApplicationCore.Mappere; using ApplicationCore.Mappere;
using WebPresentation.Filters.ModelStateValidation; using WebPresentation.Filters.ModelStateValidation;
using WebPresentation.Services;
namespace WebPresentation namespace WebPresentation
{ {
...@@ -126,7 +127,7 @@ namespace WebPresentation ...@@ -126,7 +127,7 @@ namespace WebPresentation
#endregion ADD Authentication Schema #endregion ADD Authentication Schema
services.AddSession(); services.AddSession();
services.AddScoped<IImageService,ImageService>();
services.AddScoped<StateValidationFilter>(); services.AddScoped<StateValidationFilter>();
services.AddControllersWithViews().AddNewtonsoftJson(options => services.AddControllersWithViews().AddNewtonsoftJson(options =>
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
......
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebPresentation.ViewModels
{
public interface IImageForm
{
public IFormFile ImageFile {get ;set; }
public String ImageName { get; set; }
}
}
using ApplicationDomain.Entities; using ApplicationDomain.Entities;
using Microsoft.AspNetCore.Http;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WebPresentation.ViewModels;
namespace WebPresentation.ViewModel.Identity namespace WebPresentation.ViewModel.Identity
{ {
public class RegisterationInputModel public class RegisterationInputModel : IImageForm
{ {
[Required] [Required]
[EmailAddress] [EmailAddress]
[Display(Name = "Email")] [Display(Name = "Email")]
public string Email { get; set; } public string Email { get; set; }
public IFormFile ImageFile { get; set; }
public string ImageName { get; set; }
[Required] [Required]
public string FirstName { get; set; } public string FirstName { get; set; }
[Required] [Required]
public string LastName { get; set; } public string LastName { get; set; }
public string Avatar { get; set; }
[Required] [Required]
public Patient Patient { get; set; } public PatientViewModel Patient { get; set; }
[Required] [Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 3)] [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 3)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
......
using System; using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace WebPresentation.ViewModels namespace WebPresentation.ViewModels
{ {
public class MedicineViewModel : BaseViewModel public class MedicineViewModel : BaseViewModel , IImageForm
{ {
public String TradeName { get; set; } public String TradeName { get; set; }
...@@ -12,12 +13,13 @@ namespace WebPresentation.ViewModels ...@@ -12,12 +13,13 @@ namespace WebPresentation.ViewModels
public String SideEffect { get; set; } public String SideEffect { get; set; }
public String Description { get; set; } public String Description { get; set; }
public int Price { get; set; } public int Price { get; set; }
public String Image { get; set; }
public int Dosage { get; set; } public int Dosage { get; set; }
public CategoryViewModel Category { get; set; } public CategoryViewModel Category { get; set; }
public MedicineTypeViewModel MedicineType { get; set; } public MedicineTypeViewModel MedicineType { get; set; }
public ICollection<IngredientViewModel> Ingredients { get; set; } public ICollection<IngredientViewModel> Ingredients { get; set; }
public ICollection<MedicineIngredientViewModel> MedicineIngredients { get; set; } public ICollection<MedicineIngredientViewModel> MedicineIngredients { get; set; }
public IFormFile ImageFile { get ; set; }
public string ImageName { get ; set ; }
} }
} }
using ApplicationDomain.Entities; using ApplicationDomain.Entities;
using Microsoft.AspNetCore.Http;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -7,14 +8,19 @@ using System.Threading.Tasks; ...@@ -7,14 +8,19 @@ using System.Threading.Tasks;
namespace WebPresentation.ViewModels namespace WebPresentation.ViewModels
{ {
public class PatientViewModel : BaseViewModel public class PatientViewModel : BaseViewModel , IImageForm
{ {
public String UserId { get; set; } public String UserId { get; set; }
public User User { get; set; } public User User { get; set; }
public String BIO { get; set; } public String BIO { get; set; }
public ICollection<MedicalStateViewModel> MedicalStates { get; set; } public ICollection<MedicalStateViewModel> MedicalStates { get; set; }
public IFormFile ImageFile { get; set; }
public string ImageName { get; set; }
} }
} }
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<section class="page-section bg-primary text-black mb-0"> <section class="page-section bg-primary text-black mb-0">
<h3 class="mb-5 text-uppercase text-center">Patient Registration</h3> <h3 class="mb-5 text-uppercase text-center">Patient Registration</h3>
<form method="post" asp-controller="Access" asp-action="Register"> <form method="post" asp-controller="Access" asp-action="Register" enctype="multipart/form-data">
<div class="container py-5 h-100"> <div class="container py-5 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"> <div class="col">
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
<div class="form-group row mb-4"> <div class="form-group row mb-4">
<div data-mdb-input-init class="form-outline col"> <div data-mdb-input-init class="form-outline col">
<input type="text" asp-for="@Model.Avatar" class="form-control form-control-lg" /> <input type="file" asp-for="@Model.ImageFile" class="form-control form-control-lg" />
<label class="form-label" asp-for="@Model.Avatar">Image</label> <label class="form-label" asp-for="@Model.ImageFile">Image File</label>
</div> </div>
</div> </div>
......
@model PatientViewModel @model PatientViewModel;
@{ @{
ViewData["Title"] = "Edit";
ViewData["userName"] = Model.User.FirstName + " " + Model.User.LastName;
ViewData["title"] = "Edit";
ViewBag.Avatar = Model.User.Avatar;
ViewData["Controller"] = "Home";
ViewBag.owner = Model;
} }
<section class="page-section">
<div class="container ">
<div class="row justify-content-center">
<div class="">
<div class="card shadow-sm">
<div class="card-body">
<form asp-action="Edit" class="row g-3" enctype="multipart/form-data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="col-md-6">
<label asp-for="BIO" class="form-label">Patient Personal info</label>
<input asp-for="BIO" class="form-control" />
<span asp-validation-for="BIO" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="User.FirstName" class="form-label"></label>
<input asp-for="User.FirstName" class="form-control" />
<span asp-validation-for="User.FirstName" class="text-danger"></span>
</div>
<style>
.form-control:focus {
box-shadow: none;
border-color: #BA68C8
}
.profile-button {
background: rgb(99, 39, 120);
box-shadow: none;
border: none
}
.profile-button:hover {
background: #682773
}
.profile-button:focus {
background: #682773;
box-shadow: none
}
.profile-button:active {
background: #682773;
box-shadow: none
}
.back:hover {
color: #682773;
cursor: pointer
}
.labels {
font-size: 11px
}
.add-experience:hover {
background: #BA68C8;
color: #fff;
cursor: pointer;
border: solid 1px #BA68C8
}
</style>
<section class="page-section">
<form method="post" asp-action="Edit" asp-controller="Home">
<div class="container rounded bg-white mt-5 mb-5">
<div class="row">
<div class="col-md-3 border-right">
<div class="d-flex flex-column align-items-center text-center p-3 py-5">
<img class="rounded-circle mt-5" width="150px" src="/img/@Model.User.Avatar"><span class="font-weight-bold">@Model.User.FirstName</span><span class="text-black-50">@Model.User.Email</span><span> </span>
</div>
</div>
<div class="col-md-5 border-right">
<div class="p-3 py-5">
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="text-right">Profile Settings</h4>
</div>
<div class="row mt-2">
<div class="col-md-6"> <div class="col-md-6">
<label asp-for="@Model.User.FirstName" class="labels"></label> <label asp-for="User.LastName" class="form-label"></label>
<input asp-for="@Model.User.FirstName" class="form-control"> <input asp-for="User.LastName" class="form-control" />
<span asp-validation-for="User.LastName" class="text-danger"></span>
</div> </div>
<div class="col-md-6">
<label class="labels" asp-for="@Model.User.LastName"></label> <div class="col-12">
<input type="text" class="form-control" asp-for="@Model.User.LastName"> <label asp-for="ImageFile" class="form-label">Image File</label>
<input type="file" asp-for="ImageFile" class="form-control" />
<span asp-validation-for="ImageFile" class="text-danger"></span>
</div> </div>
</div>
<div class="row mt-3">
<div class="col-md-12"><label class="labels" asp-for="@Model.BIO"></label><input type="text" class="form-control" asp-for="@Model.BIO"></div>
<div class="col-md-12"><label class="labels" asp-for="@Model.User.UserName"></label><input type="text" class="form-control" asp-for="@Model.User.UserName"></div>
</div>
<div class="row mt-3">
<div class="col-md-12"><label class="labels" asp-for="@Model.User.Avatar"></label><input type="text" class="form-control" asp-for="@Model.User.Avatar"></div>
</div> <div class="col-12 mt-4">
<div class="mt-5 text-center"><button class="btn btn-primary profile-button" role="submit" type="button">Save Profile</button></div> <input type="hidden" asp-for="Id" />
<input type="hidden" asp-for="User.Id" />
<input type="hidden" asp-for="UserId" />
<button type="submit" class="btn btn-primary">Save</button>
</div>
</form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</form> </div>
</section>
\ No newline at end of file </section>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
{ {
<div class="col-lg-4 col-md-6 d-flex flex-column align-items-stretch mb-5"> <div class="col-lg-4 col-md-6 d-flex flex-column align-items-stretch mb-5">
<div class="card m-3"> <div class="card m-3">
<img src="/img/portfolio/@item.Image" <img src="/img/portfolio/@item.ImageName"
class="card-img-top img-fluid" style="max-height:250px " class="card-img-top img-fluid" style="max-height:250px "
alt="Waterfall" /> alt="Waterfall" />
<div class="card-body"> <div class="card-body">
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<td>@ing.Dosage</td> <td>@ing.Dosage</td>
<td>@ing.ManufactureName</td> <td>@ing.ManufactureName</td>
<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?", "RemoveMedicine", @ing.Id)'>Delete</button> <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> <button class="btn btn-info btn-sm" onclick="DetailMedicine(@ing.Id)">Details</button>
</td> </td>
</tr> </tr>
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
<td> <td>
<button class="btn btn-primary" onclick="DetailMedicine( ${medicine.id})">Details</button> <button class="btn btn-primary" onclick="DetailMedicine( ${medicine.id})">Details</button>
<button class="btn btn-danger" onclick='DeleteConfirm("Delete Confirm", "Are you sure you want to delete ${medicine.name} From this medical Case" , "ReomveMedicine" ,${medicine.id})'>Delete</button> <button class="btn btn-danger" onclick='DeleteConfirm("Delete Confirm", "Are you sure you want to delete ${medicine.name} From this medical Case" ,${medicine.id})'>Delete</button>
</td> </td>
` : ` :
...@@ -305,7 +305,7 @@ ...@@ -305,7 +305,7 @@
showToast('Failed to remove medicine', 'Error'); showToast('Failed to remove medicine', 'Error');
} }
} }
async function DeleteConfirm(title, message, action,param) { async function DeleteConfirm(title, message,param) {
debugger debugger
const modalBody = document.querySelector('#item-container'); const modalBody = document.querySelector('#item-container');
modalBody.innerHTML = ` modalBody.innerHTML = `
...@@ -329,7 +329,7 @@ ...@@ -329,7 +329,7 @@
style="height: 0; background-color: transparent; opacity: .75; border-top: 2px dashed #9e9e9e;"> style="height: 0; background-color: transparent; opacity: .75; border-top: 2px dashed #9e9e9e;">
<div class="modal-footer d-flex justify-content-center border-top-0 py-4"> <div class="modal-footer d-flex justify-content-center border-top-0 py-4">
<button class="btn btn-danger" onclick="${action}(${param})" data-dismiss="modal" aria-label="Close">Delete</button> <button class="btn btn-danger" onclick="RemoveMedicine(${param})" data-dismiss="modal" aria-label="Close">Delete</button>
<button class="btn btn-info" class="close" data-dismiss="modal" aria-label="Close">Close</button> <button class="btn btn-info" class="close" data-dismiss="modal" aria-label="Close">Close</button>
</div> </div>
......
...@@ -63,9 +63,9 @@ ...@@ -63,9 +63,9 @@
</div> </div>
<div class="form-group mb-3"> <div class="form-group mb-3">
<label asp-for="Image" class="control-label">Image URL</label> <label asp-for="ImageFile" class="control-label">Image File</label>
<input asp-for="Image" class="form-control" /> <input asp-for="ImageFile" class="form-control" />
<span asp-validation-for="Image" class="text-danger"></span> <span asp-validation-for="ImageFile" class="text-danger"></span>
</div> </div>
<div class="form-group mb-4"> <div class="form-group mb-4">
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div class="row g-0"> <div class="row g-0">
<div class="col-md-4 gradient-custom text-center text-black" <div class="col-md-4 gradient-custom text-center text-black"
style="border-top-left-radius: .5rem; border-bottom-left-radius: .5rem;"> style="border-top-left-radius: .5rem; border-bottom-left-radius: .5rem;">
<img src="~/img/portfolio/@Model.Image" <img src="~/img/@Model.ImageName"
alt="Avatar" class="img-fluid my-5" style="width: 80px;" /> alt="Avatar" class="img-fluid my-5" style="width: 80px;" />
<h5>@Model.TradeName</h5> <h5>@Model.TradeName</h5>
<p>Category: @(Model.Category is null ? "":Model.Category.Name)</p> <p>Category: @(Model.Category is null ? "":Model.Category.Name)</p>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div class=""> <div class="">
<div class="card shadow-sm"> <div class="card shadow-sm">
<div class="card-body"> <div class="card-body">
<form asp-action="Edit" class="row g-3"> <form asp-action="Edit" class="row g-3" enctype="multipart/form-data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="col-md-6"> <div class="col-md-6">
...@@ -32,12 +32,7 @@ ...@@ -32,12 +32,7 @@
<input asp-for="Description" class="form-control" /> <input asp-for="Description" class="form-control" />
<span asp-validation-for="Description" class="text-danger"></span> <span asp-validation-for="Description" class="text-danger"></span>
</div> </div>
<div class="col-md-6">
<label asp-for="MedicineType" class="form-label">Description</label>
<input asp-for="MedicineType" class="form-control" />
<span asp-validation-for="MedicineType" class="text-danger"></span>
</div>
<div class="col-md-6"> <div class="col-md-6">
<label asp-for="Dosage" class="form-label">Dosage</label> <label asp-for="Dosage" class="form-label">Dosage</label>
...@@ -81,17 +76,18 @@ ...@@ -81,17 +76,18 @@
<span asp-validation-for="SideEffect" class="text-danger"></span> <span asp-validation-for="SideEffect" class="text-danger"></span>
</div> </div>
<div class="col-12"> <div class="col-12">
<label asp-for="Image" class="form-label">Image URL</label> <label asp-for="ImageFile" class="form-label">Image File</label>
<input asp-for="Image" class="form-control" /> <input type="file" asp-for="ImageFile" class="form-control" />
<span asp-validation-for="Image" class="text-danger"></span> <span asp-validation-for="ImageFile" class="text-danger"></span>
</div> </div>
<div class="col-12 mt-4"> <div class="col-12 mt-4">
<input type="hidden" asp-for="Id" /> <input type="hidden" asp-for="Id" />
<button type="submit" class="btn btn-primary">Save</button> <button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Views\Patients\" /> <Content Update="Views\Home\Edit.cshtml">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>
#pragma checksum "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5e75b0dcb377daeda9a27984f637bf1b5b1d6ba1" #pragma checksum "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "b59ddab6f4ba44be6f22ef8a97ca3c884a481a11"
// <auto-generated/> // <auto-generated/>
#pragma warning disable 1591 #pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Medicine_Details), @"mvc.1.0.view", @"/Views/Medicine/Details.cshtml")] [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Medicine_Details), @"mvc.1.0.view", @"/Views/Medicine/Details.cshtml")]
...@@ -46,7 +46,7 @@ using System; ...@@ -46,7 +46,7 @@ using System;
#line default #line default
#line hidden #line hidden
#nullable disable #nullable disable
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5e75b0dcb377daeda9a27984f637bf1b5b1d6ba1", @"/Views/Medicine/Details.cshtml")] [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"b59ddab6f4ba44be6f22ef8a97ca3c884a481a11", @"/Views/Medicine/Details.cshtml")]
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4a2f5fee0d7223f937b9f0309fc3b9062263e26d", @"/Views/_ViewImports.cshtml")] [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"4a2f5fee0d7223f937b9f0309fc3b9062263e26d", @"/Views/_ViewImports.cshtml")]
public class Views_Medicine_Details : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MedicineViewModel> public class Views_Medicine_Details : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MedicineViewModel>
{ {
...@@ -103,16 +103,16 @@ using System; ...@@ -103,16 +103,16 @@ using System;
<div class=""col-md-4 gradient-custom text-center text-black"" <div class=""col-md-4 gradient-custom text-center text-black""
style=""border-top-left-radius: .5rem; border-bottom-left-radius: .5rem;""> style=""border-top-left-radius: .5rem; border-bottom-left-radius: .5rem;"">
"); ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("img", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "5e75b0dcb377daeda9a27984f637bf1b5b1d6ba16604", async() => { __tagHelperExecutionContext = __tagHelperScopeManager.Begin("img", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "b59ddab6f4ba44be6f22ef8a97ca3c884a481a116604", async() => {
} }
); );
__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>(); __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper<global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>();
__tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper);
BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "src", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); BeginAddHtmlAttributeValues(__tagHelperExecutionContext, "src", 2, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
AddHtmlAttributeValue("", 716, "~/img/portfolio/", 716, 16, true); AddHtmlAttributeValue("", 716, "~/img/", 716, 6, true);
#nullable restore #nullable restore
#line 18 "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml" #line 18 "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml"
AddHtmlAttributeValue("", 732, Model.Image, 732, 12, false); AddHtmlAttributeValue("", 722, Model.ImageName, 722, 16, false);
#line default #line default
#line hidden #line hidden
...@@ -260,35 +260,35 @@ AddHtmlAttributeValue("", 732, Model.Image, 732, 12, false); ...@@ -260,35 +260,35 @@ AddHtmlAttributeValue("", 732, Model.Image, 732, 12, false);
#line hidden #line hidden
#nullable disable #nullable disable
WriteLiteral("</td>\r\n <td>\r\n <button class=\"btn btn-danger\""); WriteLiteral("</td>\r\n <td>\r\n <button class=\"btn btn-danger\"");
BeginWriteAttribute("ondblclick", " ondblclick=\'", 3643, "\'", 3800, 16); BeginWriteAttribute("ondblclick", " ondblclick=\'", 3637, "\'", 3794, 16);
WriteAttributeValue("", 3656, "DeleteConfirm(\"Delete", 3656, 21, true); WriteAttributeValue("", 3650, "DeleteConfirm(\"Delete", 3650, 21, true);
WriteAttributeValue(" ", 3677, "Confirm\",", 3678, 10, true); WriteAttributeValue(" ", 3671, "Confirm\",", 3672, 10, true);
WriteAttributeValue(" ", 3687, "\"Are", 3688, 5, true); WriteAttributeValue(" ", 3681, "\"Are", 3682, 5, true);
WriteAttributeValue(" ", 3692, "you", 3693, 4, true); WriteAttributeValue(" ", 3686, "you", 3687, 4, true);
WriteAttributeValue(" ", 3696, "sure", 3697, 5, true); WriteAttributeValue(" ", 3690, "sure", 3691, 5, true);
WriteAttributeValue(" ", 3701, "you", 3702, 4, true); WriteAttributeValue(" ", 3695, "you", 3696, 4, true);
WriteAttributeValue(" ", 3705, "want", 3706, 5, true); WriteAttributeValue(" ", 3699, "want", 3700, 5, true);
WriteAttributeValue(" ", 3710, "to", 3711, 3, true); WriteAttributeValue(" ", 3704, "to", 3705, 3, true);
WriteAttributeValue(" ", 3713, "delete", 3714, 7, true); WriteAttributeValue(" ", 3707, "delete", 3708, 7, true);
#nullable restore #nullable restore
#line 62 "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml" #line 62 "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml"
WriteAttributeValue(" ", 3720, ing.Ingredient.Name, 3721, 20, false); WriteAttributeValue(" ", 3714, ing.Ingredient.Name, 3715, 20, false);
#line default #line default
#line hidden #line hidden
#nullable disable #nullable disable
WriteAttributeValue(" ", 3741, "From", 3742, 5, true); WriteAttributeValue(" ", 3735, "From", 3736, 5, true);
WriteAttributeValue(" ", 3746, "this", 3747, 5, true); WriteAttributeValue(" ", 3740, "this", 3741, 5, true);
WriteAttributeValue(" ", 3751, "medicine\",", 3752, 11, true); WriteAttributeValue(" ", 3745, "medicine\",", 3746, 11, true);
WriteAttributeValue(" ", 3762, "\"ReomveIngredient\",", 3763, 20, true); WriteAttributeValue(" ", 3756, "\"ReomveIngredient\",", 3757, 20, true);
#nullable restore #nullable restore
#line 62 "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml" #line 62 "C:\Users\HASAN\Desktop\Medic\WebPresentation\Views\Medicine\Details.cshtml"
WriteAttributeValue("", 3782, ing.IngredientId, 3782, 17, false); WriteAttributeValue("", 3776, ing.IngredientId, 3776, 17, false);
#line default #line default
#line hidden #line hidden
#nullable disable #nullable disable
WriteAttributeValue("", 3799, ")", 3799, 1, true); WriteAttributeValue("", 3793, ")", 3793, 1, true);
EndWriteAttribute(); EndWriteAttribute();
WriteLiteral(">Delete</button>\r\n </td>\r\n\r\n </tr>\r\n"); WriteLiteral(">Delete</button>\r\n </td>\r\n\r\n </tr>\r\n");
#nullable restore #nullable restore
...@@ -304,7 +304,7 @@ WriteAttributeValue("", 3782, ing.IngredientId, 3782, 17, false); ...@@ -304,7 +304,7 @@ WriteAttributeValue("", 3782, ing.IngredientId, 3782, 17, false);
<div class=""row pt-1""> <div class=""row pt-1"">
<div class=""col-6 mb-3""> <div class=""col-6 mb-3"">
"); ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "5e75b0dcb377daeda9a27984f637bf1b5b1d6ba116637", async() => { __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "b59ddab6f4ba44be6f22ef8a97ca3c884a481a1116630", async() => {
WriteLiteral("Back to List"); WriteLiteral("Back to List");
} }
); );
...@@ -320,7 +320,7 @@ WriteAttributeValue("", 3782, ing.IngredientId, 3782, 17, false); ...@@ -320,7 +320,7 @@ WriteAttributeValue("", 3782, ing.IngredientId, 3782, 17, false);
Write(__tagHelperExecutionContext.Output); Write(__tagHelperExecutionContext.Output);
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n\r\n </div>\r\n <div class=\"col-6 mb-3\">\r\n "); WriteLiteral("\r\n\r\n </div>\r\n <div class=\"col-6 mb-3\">\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "5e75b0dcb377daeda9a27984f637bf1b5b1d6ba117955", async() => { __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "b59ddab6f4ba44be6f22ef8a97ca3c884a481a1117948", async() => {
WriteLiteral("Add Ingredients "); WriteLiteral("Add Ingredients ");
} }
); );
......
40babbaebe908ee8019123f902e7ae02ef0aa7c7 15cb97b8a060c155cc9b00ed27a476ac44f14fb8
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