public IActionResult ChangeHospital(int?id) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var currentUser = _userService.GetByUserName(CurrentUserName); if (currentUser == null) { throw new EntityNotFoundException(); } var hospital = currentUser.HospitalPersons .Where(hm => hm.IsManager == true) .Select(x => x.Hospital) .FirstOrDefault(h => h.Id == id); if (hospital == null) { throw new EntityNotFoundException(); } var CurrentHospital = new WorkingAreaModel { Id = hospital.Id, Name = Lng == Core.Enums.Lang.KU ? hospital.Name_Ku : hospital.Name_Ar }; HttpContext.Session.SetString("", JsonConvert.SerializeObject(CurrentHospital)); return(RedirectToAction("Index", "Home", new { area = "HospitalManager" })); }
public IActionResult ChangeClinic(int?id) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var currentUser = _userService.GetByUserName(_workContext.CurrentUserName); var currentUserClinics = from c in currentUser.ClinicPersons.Where(cm => cm.IsManager == true) select c.Clinic; var clinic = currentUserClinics.FirstOrDefault(c => c.Id == id); if (clinic == null) { throw new EntityNotFoundException(); } var CurrentClinic = new WorkingAreaModel { Id = clinic.Id, Name = clinic.Name_Ku }; HttpContext.Session.SetString("CurrentClinic", JsonConvert.SerializeObject(CurrentClinic)); return(RedirectToAction("Index", "Home", new { area = "ClinicManager" })); }