public bool IsUserRegistered(string email) { bool rtn = false; GuestUserInfo guestUserInfo = new GuestUserInfo(); ApiSelectUserByUserLogonIdReturnModel userInfo; UserServices userService = new UserServices(); userInfo = userService.GetUserByLogonId(email); SiteServices siteService = new SiteServices(); List <ApiSelectTracerSitesByUserReturnModel> sites; ApiSelectTracerSitesByUserReturnModel defaultSite; var siteID = 0; sites = siteService.GetTracerSitesByUser(userInfo.UserID, null, null); defaultSite = sites.Where(x => x.DefaultSelectedSite == 1).FirstOrDefault(); if (defaultSite == null) { defaultSite = sites.FirstOrDefault(); } if (defaultSite != null) { siteID = defaultSite.SiteID; } guestUserInfo = ValidateUser(email, siteID); if (guestUserInfo.IsRegisteredUser) { rtn = true; } return(rtn); }
public bool ValidateUserSiteAccess(int userId, int siteId) { var sites = SiteServices.GetUserSites(userId).Where(m => m.SiteID == siteId).ToList(); return(sites != null && sites.Count > 0); }
public GuestUserInfo ValidateUser(string email, int siteId) { const string FIRST_NAME = "JCRFirstName"; const string LAST_NAME = "JCRLastName"; GuestUserInfo returnUser; using (var db = new DBAMPContext()) { ApiVerifyUserByUserLogonIdReturnModel rtnData; try { rtnData = db.ApiVerifyUserByUserLogonId(email, siteId); returnUser = ParseResultforUser(rtnData); if (returnUser.UserID == 0 || (returnUser.UserID > 0 && //For External users added via Schedule & Assignments screen, consider them as new users to update user & security information returnUser.FirstName.Equals(FIRST_NAME, StringComparison.InvariantCultureIgnoreCase) && returnUser.LastName.Equals(LAST_NAME, StringComparison.InvariantCultureIgnoreCase))) { returnUser.IsNewUser = true; } returnUser.EmailAddress = email; if (returnUser.UserSiteInfo.SiteID == 0) { SiteServices siteService = new SiteServices(); List <ApiMobileGuestUserSelectSitesReturnModel> sites; ApiMobileGuestUserSelectSitesReturnModel defaultSite; using (var dbMedition = new DBMEdition01Context()) { sites = dbMedition.ApiMobileGuestUserSelectSites(returnUser.UserID, (int)Enums.EProduct.Tracers); } defaultSite = sites.Where(x => x.DefaultSelectedSite == 1).FirstOrDefault(); returnUser.UserSiteInfo.SiteID = defaultSite.SiteID; returnUser.UserSiteInfo.SiteFullName = defaultSite.SiteName; returnUser.UserSiteInfo.RoleID = (int)defaultSite.RoleID; returnUser.UserSiteInfo.SiteName = defaultSite.SiteName; returnUser.UserSiteInfo.IsTracersAccess = false; } else { returnUser.UserSiteInfo.SiteName = GetSiteFullName(siteId); } if (returnUser.IsActive && IsUserRegistered(returnUser.UserID)) { returnUser.IsRegisteredUser = true; } } catch (Exception ex) { string sqlParam = "ApiVerifyUserByUserLogonId(" + email + "," + siteId + ")"; string methodName = "JCRAPI/Business/GuestUserServices/ValidateUser"; exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, siteId, sqlParam, string.Empty); return(null); } } return(returnUser); }