public async Task<UserProfile> GetUserProfile() { UserIdentityEntity userIdentityEntity = userIdentityRepository.GetAll().LastOrDefault(); UserProfileEntity userProfileEntity = null; userProfile = null; if (userIdentityEntity != null && !string.IsNullOrEmpty(userIdentityEntity.Email)) { userProfile = await userService.GetUserProfileByAuthLocalId(userIdentityEntity.LocalId); //Below code: tries to get latest data from server (and update cached data), otherwise get from cached data if (userProfile == null) { Navigator.Instance.OkAlert("Alert", "Currently in offline mode due to issue on server. Your profile is temporarily not synced.", "OK"); userProfileEntity = userProfileRepository.GetUserProfile(userIdentityEntity.Email); userProfile = ConvertProfileEntityToUserProfile(userProfileEntity); } else { var row = userProfileRepository.CreateOrUpdate(GetUserProfileEntity()); if (row < 0) { Navigator.Instance.OkAlert("Alert", "There is an issue trying to update your profile onto your device from server.", "OK"); } } } return userProfile; }
public int Insert(UserIdentityEntity user, IConnectionFactory connectionFactory) { var id = 0; try { using (var connection = connectionFactory.Create()) { id = connection.ExecuteScalar <int>(SqlCommandStorageService.UserIdentityRepositoryInsert(), new { userType = user.UserType, userIp = user.UserIp, userBrowser = user.UserBrowser, userRegdate = user.UserRegDate, userEmail = user.Email, userEmailConfirmed = user.EmailConfirmed, passwordHash = user.PasswordHash, securityStamp = user.SecurityStamp, phoneNumber = user.PhoneNumber, phoneNumberConfirmed = user.PhoneNumberConfirmed, twoFactorEnabled = user.TwoFactorEnabled, lockoutEndDateUtc = user.LockoutEndDateUtc, lockoutEnable = user.LockoutEnabled, accessFailedCount = user.AccessFailedCount, userName = user.UserName, userBirthday = user.UserBirthday, userGender = user.UserGender, userLastVisit = user.UserLastVisit, userLastMark = user.UserLastMark, userLastPage = user.UserLastPage, userInactiveReason = user.UserInactiveReason, userInactiveTime = user.UserInactiveTime, userLang = user.UserLang, userTimeZone = user.UserTimeZone, userDateFormat = user.UserDateFormat, userRank = user.UserRank, userNotify = user.UserNotify, userNotify_pm = user.UserNotifyPm, userAvatar = user.UserAvatar, userSignature = user.UserSignature, userFrom = user.UserFrom, userSteam = user.UserSteam, userSkype = user.UserSkype, userIcq = user.UserIcq, userVk = user.UserVk, userFb = user.UserFb, userWebsite = user.UserWebSite, userProfession = user.UserProfession, userInterests = user.UserInterests }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(id); }
public void Delete(UserIdentityEntity user, IConnectionFactory connectionFactory) { try { Delete(user.Id, connectionFactory); } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Insert(UserIdentityEntity user, int groupId, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserGroupsIdentityInsert(), new { userId = user.Id, groupId, primaryGroup = true }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserGroupsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Insert(UserIdentityEntity user, UserLoginInfo login, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserLoginsIdentityRepositoryInsert(), new { loginProvider = login.LoginProvider, providerKey = login.ProviderKey, userId = user.Id }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserExternalLoginsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Delete(UserIdentityEntity user, Claim claim, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserClaimIsdentityRepositoryDelete(), new { userId = user.Id, claimValue = claim.Value, claimType = claim.Type }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserClaimIsdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public UserIdentityEntity GetUserByEmail(string email, IConnectionFactory connectionFactory) { UserIdentityEntity userIdentityEntity = new UserIdentityEntity(); try { using (var connection = connectionFactory.Create()) { userIdentityEntity = connection.Query <UserIdentityEntity>(SqlCommandStorageService.UserIdentityRepositoryGetUserByEmail(), new { email }).FirstOrDefault(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(userIdentityEntity); }
public UserIdentityEntity GetUserIdentity() { UserIdentityEntity result = null; try { using (SQLiteConnection con = new SQLiteConnection(dbName)) { con.CreateTable <UserIdentityEntity>(); //result = con.Query<UserIdentityEntity>("select * from UserIdentity where Principal = ?", Constants.PRINCIPAL).LastOrDefault(); result = con.Table <UserIdentityEntity>().Where(p => p.Principal == Constants.PRINCIPAL)?.LastOrDefault();//.Single(); } } catch (Exception ex) { } return(result); }
public int CreateOrUpdate(UserIdentityEntity userIdentity) { int rows = -1; userIdentity.Principal = Constants.PRINCIPAL; try { using (SQLiteConnection con = new SQLiteConnection(dbName)) { con.CreateTable <UserIdentityEntity>(); rows = con.InsertOrReplace(userIdentity); } } catch (Exception ex) { } return(rows); }
public async Task <bool> VerifyUserPasswordAsync(long userId, string password) { UserIdentityEntity userIdentity = await GetFirstByUserIdAsync(userId); return(userIdentity != null && EncryptUtil.Verify(userIdentity.Credential, password)); }