public async Task LoadSession() { if (CacheProvider.IsSet(CacheKey.LoggedConsultant)) { consultant = CacheProvider.Get <Consultant> (CacheKey.LoggedConsultant); return; } ConsultantSession conSession = SessionFactory.ReadSession <ConsultantSession>(SessionKeys.LoggedConsultant); // may consultant session na, so kunin nalang natin ung info nya. if (conSession != null && conSession.IsSet) { consultant = await conService.GetConsultantByUsername(conSession.Username); } // i-load muna ung consultant session from account session ConsultantSessionLoader conLoader = new ConsultantSessionLoader(conService); bool isLoaded = await conLoader.LoadConsultantSession(); if (isLoaded) { consultant = conLoader.LoadedConsultant; CacheProvider.Set(CacheKey.LoggedConsultant, consultant); } }
public async Task <bool> LoadConsultantSession() { AccountSession session = SessionFactory.ReadSession <AccountSession>(SessionKeys.LoginKey); if (session.AccountType != AccountType.Consultant) { return(false); } // account is consultant, so get its info LoadedConsultant = await conService.GetConsultantByUsername(session.Username); // add it to consultant session ConsultantSession conSession = SessionFactory.CreateSession <ConsultantSession> (SessionKeys.LoggedConsultant); conSession.AddConsultantSession(LoadedConsultant); return(LoadedConsultant != null); }
public async Task LoadSession() { ConsultantSession conSession = SessionFactory.ReadSession <ConsultantSession>(SessionKeys.LoggedConsultant); // may consultant session na, so kunin nalang natin ung info nya. if (conSession != null && conSession.IsSet) { consultant = await conService.GetConsultantByUsername(conSession.Username); } // i-load muna ung consultant session from account session ConsultantSessionLoader conLoader = new ConsultantSessionLoader(conService); bool isLoaded = await conLoader.LoadConsultantSession(); if (isLoaded) { consultant = conLoader.LoadedConsultant; } // pag may laman, may na-load kaya != // return consultant != null; }