public LocalUser(AbstractLogger logger, IDisplayName displayName, string swid, IList <IInternalFriend> friends, AgeBandType ageBandType, IDatabase database, IUserDatabase userDatabase, IInternalRegistrationProfile registrationProfile, IMixWebCallFactory mixWebCallFactory, IGuestControllerClient guestControllerClient, INotificationQueue notificationQueue, IEncryptor encryptor, IEpochTime epochTime) { DisplayName = displayName; FirstName = registrationProfile.FirstName; Swid = swid; Id = swid; this.logger = logger; this.registrationProfile = registrationProfile; this.mixWebCallFactory = mixWebCallFactory; this.friends = friends; this.ageBandType = ageBandType; this.database = database; this.userDatabase = userDatabase; incomingFriendInvitations = new List <IInternalIncomingFriendInvitation>(); outgoingFriendInvitations = new List <IInternalOutgoingFriendInvitation>(); oldInvitationIds = new List <long>(); unidentifiedUsers = new List <IInternalUnidentifiedUser>(); this.guestControllerClient = guestControllerClient; this.notificationQueue = notificationQueue; this.encryptor = encryptor; this.epochTime = epochTime; guestControllerClient.OnLegalMarketingUpdateRequired += delegate(object sender, AbstractLegalMarketingUpdateRequiredEventArgs e) { this.OnLegalMarketingUpdateRequired(this, e); }; }
private static void HandleUpdateProfileResult(AbstractLogger logger, IDatabase database, string swid, IEpochTime epochTime, GuestControllerResult <ProfileResponse> result, IInternalRegistrationProfile profile, Action <IUpdateProfileResult> callback) { try { if (!result.Success) { callback(new UpdateProfileResult(success: false, null)); } else { IList <IInvalidProfileItemError> registerProfileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error); if (result.Response.data == null) { callback(new UpdateProfileResult(success: false, registerProfileItemErrors)); } else { ProfileData profileData = result.Response.data; if (profileData.displayName != null) { database.UpdateSessionDocument(swid, delegate(SessionDocument doc) { doc.DisplayNameText = profileData.displayName.displayName; doc.ProposedDisplayName = profileData.displayName.proposedDisplayName; doc.ProposedDisplayNameStatus = profileData.displayName.proposedStatus; doc.FirstName = profileData.profile.firstName; doc.AccountStatus = profileData.profile.status; doc.LastProfileRefreshTime = epochTime.Seconds; }); } profile.Update(profileData.profile, profileData.displayName, profileData.marketing); callback(new UpdateProfileResult(success: true, registerProfileItemErrors)); } } } catch (Exception arg) { logger.Critical("Unhandled exception: " + arg); callback(new UpdateProfileResult(success: false, null)); } }
public static void UpdateProfile(AbstractLogger logger, IGuestControllerClient guestControllerClient, IDatabase database, string swid, IEpochTime epochTime, IInternalRegistrationProfile profile, string firstName, string lastName, string displayName, string email, string parentEmail, DateTime?dateOfBirth, IEnumerable <KeyValuePair <IMarketingItem, bool> > marketingAgreements, IEnumerable <ILegalDocument> acceptedLegalDocuments, Action <IUpdateProfileResult> callback) { try { Dictionary <string, string> dictionary = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(firstName)) { dictionary.Add("firstName", firstName); } if (!string.IsNullOrEmpty(lastName)) { dictionary.Add("lastName", lastName); } if (!string.IsNullOrEmpty(email)) { dictionary.Add("email", email); } if (!string.IsNullOrEmpty(parentEmail)) { dictionary.Add("parentEmail", parentEmail); } if (dateOfBirth.HasValue) { string value = dateOfBirth.Value.ToString("yyyy-MM-dd"); dictionary.Add("dateOfBirth", value); } List <Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem> marketing = marketingAgreements?.Select((KeyValuePair <IMarketingItem, bool> pair) => new Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem { code = pair.Key.Id, subscribed = pair.Value }).ToList(); List <string> legalAssertions = acceptedLegalDocuments?.Select((ILegalDocument doc) => doc.Id).ToList(); SessionDocument sessionDocument = database.GetSessionDocument(swid); guestControllerClient.UpdateProfile(new UpdateProfileRequest { etag = sessionDocument.GuestControllerEtag, profile = dictionary, marketing = marketing, displayName = new RegisterDisplayName { proposedDisplayName = displayName }, legalAssertions = legalAssertions }, delegate(GuestControllerResult <ProfileResponse> r) { HandleUpdateProfileResult(logger, database, swid, epochTime, r, profile, callback); }); } catch (Exception arg) { logger.Critical("Unhandled exception: " + arg); callback(new UpdateProfileResult(success: false, null)); } }