public JsonResult encryptpatientlogin(string patientloginid, string PIN) { try { PatientLoginView _result = null; User luser = null; string loginsessionId = ""; if (!string.IsNullOrEmpty(patientloginid) && !string.IsNullOrEmpty(PIN)) { luser = lIUserRepository.getUserWithEncryptPassword(patientloginid, PIN, 5); } if (luser == null && !string.IsNullOrEmpty(patientloginid)) { luser = lIUserRepository.getUser(patientloginid); } if (luser != null && !string.IsNullOrEmpty(luser.EncryptPasswrod)) { _result = IPatient.PatientLoginsReturnPatientLoginViewUsingPatientLoginIdWithEncryptPin(patientloginid.ToLower(), PIN); if (_result != null) { loginsessionId = luser.LoginSessionId; if (!string.IsNullOrEmpty(loginsessionId)) { lISessionAuditTrailRepository.UpdateSessionAuditTrail(luser.UserId, "API", "Forced Logout"); } luser = lIUserRepository.getUserWithEncryptPassword(patientloginid, PIN, 5); lISessionAuditTrailRepository.InsertSessionAuditTrail(luser, "API", "Open", loginsessionId); _result.PatientFirstName = _result.PatientFirstName.Split(new char[0]).Length > 0 ? _result.PatientFirstName.Split(new char[0])[0] : _result.PatientFirstName; return(Json(new { Status = (int)HttpStatusCode.OK, SessionId = _result.LoginSessionId, Patient = _result, result = "success", TimeZone = DateTime.UtcNow.ToString("s") })); } else { return(Json(new { Status = (int)1, SessionId = "", result = "UserID or Password does not match", TimeZone = DateTime.UtcNow.ToString("s") })); } } else if (luser != null && string.IsNullOrEmpty(luser.Password)) { if (luser.Type == ConstantsVar.Patient) { return(Json(new { Status = (int)3, SessionId = "", result = "Patient's Encrypt PIN has not been set", TimeZone = DateTime.UtcNow.ToString("s") })); } else { return(Json(new { Status = (int)3, SessionId = "", result = "User's Encrypt Password has not been set", TimeZone = DateTime.UtcNow.ToString("s") })); } } else { return(Json(new { Status = (int)2, SessionId = "", result = "Patient Details is not found", TimeZone = DateTime.UtcNow.ToString("s") })); } } catch (Exception ex) { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, SessionId = "", result = "failed", TimeZone = DateTime.UtcNow.ToString("s") })); } }
public PatientLoginView PatientLoginsReturnPatientLoginView(string patientPhone, string PIN) { PatientLoginView result = null; try { var _patient = (from p in context.Patient.Where(p => p.PhoneNumber == patientPhone && p.Pin == int.Parse(PIN)) select p).FirstOrDefault(); if (_patient != null) { _patient.LoginSessionId = Guid.NewGuid(); context.Entry(_patient).State = EntityState.Modified; context.SaveChanges(); result = (from p in context.Patient join rx in context.PatientRx on p.PatientId equals rx.PatientId join therapist in context.User on p.Therapistid equals therapist.UserId into the from ltherapist in the.DefaultIfEmpty() join provider in context.User on p.ProviderId equals provider.UserId into pro from lprovider in pro.DefaultIfEmpty() join patientconfig in context.PatientConfiguration on p.PatientId equals patientconfig.PatientId into pconfig from patconfig in pconfig.DefaultIfEmpty() join vsee in context.User on p.PatientLoginId equals vsee.UserId where p.PatientId == _patient.PatientId select new PatientLoginView { PatientLoginId = p.PatientLoginId, PatientId = p.PatientId, PatientFirstName = p.PatientName, TherapistId = ltherapist != null ? ltherapist.UserId : "", TherapistName = ltherapist != null ? ltherapist.Name : "", TherapistContactNo = ltherapist != null ? ltherapist.Phone : "", ProviderId = lprovider != null ? lprovider.UserId : "", ProviderName = lprovider != null ? lprovider.Name : "", ProviderContactNo = lprovider != null ? lprovider.Phone : "", InstallerId = patconfig != null ? (from p in context.User where p.UserId == patconfig.InstallerId select p).FirstOrDefault().UserId : "", InstallerName = patconfig != null ? (from p in context.User where p.UserId == patconfig.InstallerId select p).FirstOrDefault().Name : "", InstallerContactNo = patconfig != null ? (from p in context.User where p.UserId == patconfig.InstallerId select p).FirstOrDefault().Phone : "", RxStartDate = rx.RxStartDate.HasValue ? Convert.ToDateTime(rx.RxStartDate).ToString("yyyy-MM-dd'T'HH:mm:ss") : "", RxEndDate = rx.RxEndDate.HasValue ? Convert.ToDateTime(rx.RxEndDate).ToString("yyyy-MM-dd'T'HH:mm:ss") : "", LoginSessionId = p.LoginSessionId, VSeeId = vsee.Vseeid }).FirstOrDefault(); } } catch (Exception ex) { } return(result); }
public JsonResult patientlogin(string patientloginid, string PIN) { PatientLoginView _result = null; User luser = null; string loginsessionId = ""; if (!string.IsNullOrEmpty(patientloginid)) { luser = lIUserRepository.getUser(patientloginid, PIN, 5); loginsessionId = luser.LoginSessionId; } if (luser != null) { _result = IPatient.PatientLoginsReturnPatientLoginViewUsingPatientLoginId(patientloginid.ToLower(), PIN); if (_result != null) { if (!string.IsNullOrEmpty(loginsessionId)) { lISessionAuditTrailRepository.UpdateSessionAuditTrail(luser.UserId, "API", "Forced Logout"); } luser = lIUserRepository.getUser(patientloginid, PIN, 5); lISessionAuditTrailRepository.InsertSessionAuditTrail(luser, "API", "Open", loginsessionId); _result.PatientFirstName = _result.PatientFirstName.Split(new char[0]).Length > 0 ? _result.PatientFirstName.Split(new char[0])[0] : _result.PatientFirstName; return(Json(new { Status = (int)HttpStatusCode.OK, SessionId = _result.LoginSessionId, Patient = _result, result = "success", TimeZone = DateTime.UtcNow.ToString("s") })); } else { return(Json(new { Status = (int)HttpStatusCode.BadRequest, SessionId = "", result = "Failed", TimeZone = DateTime.UtcNow.ToString("s") })); } } else { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, SessionId = "", result = "Internal server error", TimeZone = DateTime.UtcNow.ToString("s") })); } }
public PatientLoginView PatientLoginsReturnPatientLoginViewUsingPatientLoginIdWithEncryptPin(string patientloinId, string PIN) { PatientLoginView result = null; try { var _patient = (from p in context.Patient.Where(p => p.PatientLoginId == patientloinId && p.EncryptPin == PIN) select p).FirstOrDefault(); if (_patient != null) { _patient.LoginSessionId = Guid.NewGuid(); context.Entry(_patient).State = EntityState.Modified; var res = context.SaveChanges(); if (res > 0) { User luser = (from p in context.User where p.UserId == patientloinId && p.EncryptPasswrod == PIN && p.Type == 5 select p).FirstOrDefault(); if (luser != null) { luser.LoginSessionId = _patient.LoginSessionId.ToString(); context.Entry(luser).State = EntityState.Modified; int response = context.SaveChanges(); if (response > 0) { result = (from p in context.Patient join rx in context.PatientRx on p.PatientId equals rx.PatientId join therapist in context.User on p.Therapistid equals therapist.UserId into the from ltherapist in the.DefaultIfEmpty() join provider in context.User on p.ProviderId equals provider.UserId into pro from lprovider in pro.DefaultIfEmpty() join patientconfig in context.PatientConfiguration on p.PatientId equals patientconfig.PatientId into pconfig from patconfig in pconfig.DefaultIfEmpty() join vsee in context.User on p.PatientLoginId equals vsee.UserId into vseeconfig from vseeinfo in vseeconfig.DefaultIfEmpty() where p.PatientId == _patient.PatientId select new PatientLoginView { PatientLoginId = p.PatientLoginId, PatientId = p.PatientId, PatientFirstName = p.PatientName, TherapistId = ltherapist != null ? ltherapist.UserId : "", TherapistName = ltherapist != null ? ltherapist.Name : "", TherapistContactNo = ltherapist != null ? ltherapist.Phone : "", ProviderId = lprovider != null ? lprovider.UserId : "", ProviderName = lprovider != null ? lprovider.Name : "", ProviderContactNo = lprovider != null ? lprovider.Phone : "", InstallerId = patconfig != null ? (from p in context.User where p.UserId == patconfig.InstallerId select p).FirstOrDefault().UserId : "", InstallerName = patconfig != null ? (from p in context.User where p.UserId == patconfig.InstallerId select p).FirstOrDefault().Name : "", InstallerContactNo = patconfig != null ? (from p in context.User where p.UserId == patconfig.InstallerId select p).FirstOrDefault().Phone : "", RxStartDate = rx.RxStartDate.HasValue ? Convert.ToDateTime(rx.RxStartDate).ToString("yyyy-MM-dd'T'HH:mm:ss") : "", RxEndDate = rx.RxEndDate.HasValue ? Convert.ToDateTime(rx.RxEndDate).ToString("yyyy-MM-dd'T'HH:mm:ss") : "", LoginSessionId = p.LoginSessionId, VSeeId = vseeinfo != null ? vseeinfo.Vseeid : "" }).FirstOrDefault(); } } } } } catch (Exception ex) { } return(result); }