public ActionResult CreatePassword(CreateNewPasswordModel model) { try { if (!ModelState.IsValid) { return(View(model)); } model.OldPassword = ""; ApiHeader apiHeader = _clinicService.ActiveUser(BaseApiHeader, model); apiHeader.Hospitals = apiHeader.Hospitals?.Where(x => x.Status == 1).ToList(); 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); } if (apiHeader.Hospitals != null && apiHeader.Hospitals.Count > 0) { var cookieHospital = new HttpCookie(CookieConstant.HospitalSelected) { Value = JsonConvert.SerializeObject(apiHeader.Hospitals[0]), Expires = Utils.UnixTimeStampToDateTime(apiHeader.SessionExpired) }; HttpContext.Response.Cookies.Add(cookieHospital); apiHeader.HospitalSelected = apiHeader.Hospitals[0].HospitalId; apiHeader.HospitalSubType = apiHeader.Hospitals[0].SubType; apiHeader.HospitalRoles = apiHeader.Hospitals[0].Roles; apiHeader.HospitalName = apiHeader.Hospitals[0].Name; } //if (apiHeader.User != null) // apiHeader.User.DoctorInfos = null; var cookie = new HttpCookie(CookieConstant.ApiHeader) { Value = JsonConvert.SerializeObject(apiHeader), Expires = Utils.UnixTimeStampToDateTime(apiHeader.SessionExpired) }; HttpContext.Response.Cookies.Add(cookie); HttpContext.Response.Cookies.Add(new HttpCookie("timezone") { Value = model.TimeZone, Expires = Utils.UnixTimeStampToDateTime(apiHeader.SessionExpired) }); if (apiHeader.Hospitals != null && apiHeader.Hospitals.Count == 0) { RemoveCookie(); } return(RedirectToAction("Index", "Appointment")); //model.OldPassword = ""; //var apiHeader = new ApiHeader(); //apiHeader.UserId = result[1].Value.ToString(); //apiHeader.SessionId = result[0].Value.ToString(); //_clinicService.CreatePassword(apiHeader, model); //ViewBag.email = model.Email; //ViewBag.password = model.Password; //ViewBag.createPass = "******"; //return View(); } catch (ApiException) { //TempData[GlobalConstant.ErrorTemp] = ex.Message; // ignored return(RedirectToAction("CreatePasswordError")); } }