/** * Get user details. */ public static async Task <GetUserDetailsResponse> GetUserDetails(AmazonDynamoDBClient dbClient, string loggedInUserId) { Debug.Untested(); Debug.AssertValid(dbClient); Debug.AssertID(loggedInUserId); User user = await IdentityServiceLogicLayer.FindUserByID(dbClient, loggedInUserId); Debug.AssertValid(user); GetUserDetailsResponse retVal = new GetUserDetailsResponse() { emailAddress = user.EmailAddress, givenName = user.GivenName, familyName = user.FamilyName, preferredName = user.PreferredName, fullName = user.FullName, dateOfBirth = APIHelper.APIDateStringFromDate(user.DateOfBirth), gender = user.Gender, address1 = user.Address1, address2 = user.Address2, address3 = user.Address3, address4 = user.Address4, city = user.City, region = user.Region, country = user.Country, postalCode = user.PostalCode, phoneNumber = user.PhoneNumber, phoneNumberVerified = APIHelper.APIDateTimeStringFromDateTime(user.PhoneNumberVerified), newEmailAddress = user.NewEmailAddress, allowNonEssentialEmails = user.AllowNonEssentialEmails, totalTicketsPurchased = user.TotalTicketsPurchased, ticketsPurchasedInCurrentGame = user.TicketsPurchasedInCurrentGame, preferredLanguage = user.PreferredLanguage, preferredCurrency = user.PreferredCurrency, preferredTimeZone = user.PreferredTimeZone, maxDailySpendingAmount = user.MaxDailySpendingAmount, newMaxDailySpendingAmount = user.NewMaxDailySpendingAmount, newMaxDailySpendingAmountTime = APIHelper.APIDateTimeStringFromDateTime(user.NewMaxDailySpendingAmountTime), maxTimeLoggedIn = user.MaxTimeLoggedIn, newMaxTimeLoggedIn = user.NewMaxTimeLoggedIn, newMaxTimeLoggedInTime = APIHelper.APIDateTimeStringFromDateTime(user.NewMaxTimeLoggedInTime), excludeUntil = APIHelper.APIDateTimeStringFromDateTime(user.ExcludeUntil), newExcludeUntil = APIHelper.APIDateTimeStringFromDateTime(user.NewExcludeUntil), newExcludeUntilTime = APIHelper.APIDateTimeStringFromDateTime(user.NewExcludeUntilTime) }; return(retVal); }
/** * Add a user record to the data store. */ internal static async Task AddUser(AmazonDynamoDBClient dbClient, User user) { Debug.Untested(); Debug.AssertValid(dbClient); Debug.AssertValid(user); Debug.AssertID(user.ID); Dictionary <string, AttributeValue> item = new Dictionary <string, AttributeValue>(); item.Add(FIELD_USERS_ID, new AttributeValue(user.ID)); item.Add(FIELD_USERS_CLIENT_ID, new AttributeValue(user.ClientID)); item.Add(FIELD_USERS_GIVEN_NAME, new AttributeValue(user.GivenName)); item.Add(FIELD_USERS_FAMILY_NAME, new AttributeValue(user.FamilyName)); item.Add(FIELD_USERS_PREFERRED_NAME, new AttributeValue(user.PreferredName)); item.Add(FIELD_USERS_FULL_NAME, new AttributeValue(user.FullName)); item.Add(FIELD_USERS_EMAIL_ADDRESS, new AttributeValue(user.EmailAddress)); item.Add(FIELD_USERS_EMAIL_ADDRESS_VERIFIED, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.EmailAddressVerified))); item.Add(FIELD_USERS_NEW_EMAIL_ADDRESS, new AttributeValue(user.NewEmailAddress)); item.Add(FIELD_USERS_PASSWORD_HASH, new AttributeValue(user.PasswordHash)); item.Add(FIELD_USERS_BLOCKED, new AttributeValue { BOOL = user.Blocked }); item.Add(FIELD_USERS_LOCKED, new AttributeValue { BOOL = user.Locked }); item.Add(FIELD_USERS_DATE_OF_BIRTH, new AttributeValue(APIHelper.APIDateStringFromDate(user.DateOfBirth))); item.Add(FIELD_USERS_GENDER, new AttributeValue { N = user.Gender.ToString() }); item.Add(FIELD_USERS_ADDRESS_1, new AttributeValue(user.Address1)); item.Add(FIELD_USERS_ADDRESS_2, new AttributeValue(user.Address2)); item.Add(FIELD_USERS_ADDRESS_3, new AttributeValue(user.Address3)); item.Add(FIELD_USERS_ADDRESS_4, new AttributeValue(user.Address4)); item.Add(FIELD_USERS_CITY, new AttributeValue(user.City)); item.Add(FIELD_USERS_REGION, new AttributeValue(user.Region)); item.Add(FIELD_USERS_COUNTRY, new AttributeValue(user.Country)); item.Add(FIELD_USERS_POSTAL_CODE, new AttributeValue(user.PostalCode)); item.Add(FIELD_USERS_PHONE_NUMBER, new AttributeValue(user.PhoneNumber)); item.Add(FIELD_USERS_PHONE_NUMBER_VERIFIED, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.PhoneNumberVerified))); item.Add(FIELD_USERS_LAST_LOGGED_IN, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.LastLoggedIn))); item.Add(FIELD_USERS_LAST_LOGGED_OUT, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.LastLoggedOut))); item.Add(FIELD_USERS_CLOSED, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.Closed))); item.Add(FIELD_USERS_IS_ANONYMISED, new AttributeValue { BOOL = user.IsAnonymised }); item.Add(FIELD_USERS_DELETED, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.Deleted))); item.Add(FIELD_USERS_ALLOW_NON_ESSENTIAL_EMAILS, new AttributeValue { BOOL = user.AllowNonEssentialEmails }); item.Add(FIELD_USERS_ANEE_ON_TIMESTAMP, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.ANEEOnTimestamp))); item.Add(FIELD_USERS_ANEE_OFF_TIMESTAMP, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.ANEEOffTimestamp))); item.Add(FIELD_USERS_TOTAL_TICKETS_PURCHASED, new AttributeValue { N = user.TotalTicketsPurchased.ToString() }); item.Add(FIELD_USERS_TICKETS_PURCHASED_IN_CURRENT_GAME, new AttributeValue { N = user.TicketsPurchasedInCurrentGame.ToString() }); item.Add(FIELD_USERS_PREFERRED_LANGUAGE, new AttributeValue(user.PreferredLanguage)); item.Add(FIELD_USERS_PREFERRED_CURRENCY, new AttributeValue(user.PreferredCurrency)); item.Add(FIELD_USERS_PREFERRED_TIME_ZONE, new AttributeValue(user.PreferredTimeZone)); item.Add(FIELD_USERS_FAILED_LOGIN_ATTEMPTS, new AttributeValue { N = user.FailedLoginAttempts.ToString() }); item.Add(FIELD_USERS_KYC_STATUS, new AttributeValue(user.KYCStatus)); item.Add(FIELD_USERS_KYC_TIMESTAMP, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.KCYTimestamp))); item.Add(FIELD_USERS_MAX_DAILY_SPENDING_AMOUNT, new AttributeValue { N = user.MaxDailySpendingAmount.ToString() }); item.Add(FIELD_USERS_NEW_MAX_DAILY_SPENDING_AMOUNT, new AttributeValue { N = user.NewMaxDailySpendingAmount.ToString() }); item.Add(FIELD_USERS_NEW_MAX_DAILY_SPENDING_AMOUNT_TIME, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.NewMaxDailySpendingAmountTime))); item.Add(FIELD_USERS_MAX_TIME_LOGGED_IN, new AttributeValue { N = user.MaxTimeLoggedIn.ToString() }); item.Add(FIELD_USERS_NEW_MAX_TIME_LOGGED_IN, new AttributeValue { N = user.NewMaxTimeLoggedIn.ToString() }); item.Add(FIELD_USERS_NEW_MAX_TIME_LOGGED_IN_TIME, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.NewMaxTimeLoggedInTime))); item.Add(FIELD_USERS_EXCLUDE_UNTIL, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.ExcludeUntil))); item.Add(FIELD_USERS_NEW_EXCLUDE_UNTIL, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.NewExcludeUntil))); item.Add(FIELD_USERS_NEW_EXCLUDE_UNTIL_TIME, new AttributeValue(APIHelper.APIDateTimeStringFromDateTime(user.NewExcludeUntilTime))); item.Add(FIELD_USERS_PERMISSIONS, new AttributeValue { SS = user.Permissions }); PutItemResponse putResponse = await dbClient.PutItemAsync(DATASET_USERS, item); Debug.AssertValid(putResponse); //??++Check response? }