public ActionResult Edit(int id) { Models.Hospital.AddViewModel model = new AddViewModel(); //select list model.CitySelectList = GetCitySelectList(); try { var result = _hospitalService.GetById(id); if (result == null) { return(View("_ErrorNotExist")); } model.Id = result.Id; model.Name = result.Name; model.Phone = result.Phone; model.Address = result.Address; model.CityCode = result.CityCode; } catch { ViewBag.ErrorMessage = "Record Not Found"; return(View("_ErrorNotExist")); } return(View(model)); }
public IActionResult GetById(int id) { var result = _hospitalService.GetById(id); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Edit(string id) { HospitalEditInputModel hospitalEditInputModel = (await hospitalService.GetById(id) ).To <HospitalEditInputModel>(); if (hospitalEditInputModel == null) { return(Redirect("")); } return(View(hospitalEditInputModel)); }
public ActionResult LoginClinic(string id) { try { var clinic = _clinicService.GetById(BaseApiHeader, id); var oldCookie = HttpContext.Request.Cookies[CookieConstant.ApiHeader]; if (oldCookie != null) { oldCookie.Expires = DateTime.Now.AddDays(-1); HttpContext.Response.Cookies.Add(oldCookie); } var oldCookieHospital = HttpContext.Request.Cookies[CookieConstant.HospitalSelected]; if (oldCookieHospital != null) { oldCookieHospital.Expires = DateTime.Now.AddDays(-1); HttpContext.Response.Cookies.Add(oldCookieHospital); } var newApiHeader = BaseApiHeader; newApiHeader.HospitalSelected = clinic.Id; newApiHeader.HospitalRoles = new List <int> { (int)UserRole.Administrator }; newApiHeader.HospitalSubType = (int)UserType.PracticeManager; newApiHeader.HospitalName = clinic.ClinicName; //if (newApiHeader.User != null) // newApiHeader.User.DoctorInfos = null; var cookie = new HttpCookie(CookieConstant.ApiHeader) { Value = JsonConvert.SerializeObject(newApiHeader), Expires = Utils.UnixTimeStampToDateTime(newApiHeader.SessionExpired) }; HttpContext.Response.Cookies.Add(cookie); var hospitalCookie = new HttpCookie(CookieConstant.HospitalSelected) { Value = JsonConvert.SerializeObject(clinic), Expires = Utils.UnixTimeStampToDateTime(newApiHeader.SessionExpired) }; HttpContext.Response.Cookies.Add(hospitalCookie); return(RedirectToAction("Index", "Appointment")); } catch (ApiException) { return(RedirectToAction("ActiveClinics")); } }