Hello everyone
I have developed a profile module where i can change some profile properties, as well as email, name etc.
I have 2 ajax functions, the first one calls a web service to save that profile values, the second one (calls another web service) is only called if first ajax response was successful to get that user profile properties and redraw them on the website.
I have been debugging and i'm sure it goes step by step over this (the web service to save values):
public HttpResponseMessage PostSaveDisplayNameEmail(user usuario)
{
UserInfo me = new UserInfo();
me = UserController.GetUserById(PortalSettings.PortalId, UserInfo.UserID);
try
{
string returnName = PostCheckNombre(usuario);
string returnEmail = PostCheckemail(usuario);
if (returnEmail == "OK" || returnEmail == "isYourEmail")
{
me.DisplayName = usuario.displayname;
me.Email = usuario.email;
me.FirstName = usuario.nombreUsuario;
me.LastName = usuario.apellidoUsuario;
me.Profile.SetProfileProperty("Facebook", usuario.ProfilePropertyFB);
me.Profile.SetProfileProperty("Twitter", usuario.ProfilePropertyTW);
me.Profile.SetProfileProperty("Google", usuario.ProfilePropertyGO);
ProfileController.UpdateUserProfile(me,me.Profile.ProfileProperties);
int portalId = me.PortalID;
UserController.UpdateUser(portalId, me);
}
return Request.CreateResponse(HttpStatusCode.OK, "dataSaved");
}
[catch block etc...]
Now, if i pause debugging at last line, i can see "me" userinfo object contains the correct values for each parameter inside me.Profile.ProfileProperties.
But when this finishes and jquery calls second web service after 1st ajax.complete(), this code is returning old userinfo.Profile.ProfileProperties that are not the same ones saved at first web service.
This is the code:
public HttpResponseMessage GetUserInfo()
{
UserInfo myDnnUser = new UserInfo();
myDnnUser = UserController.GetUserById(PortalSettings.PortalId, UserInfo.UserID);
try
{
user U1 = new user
{
email = myDnnUser.Email,
displayname = myDnnUser.DisplayName,
fechaCreacion = myDnnUser.Membership.CreatedDate.ToString(),
fechaUltimaActividad = myDnnUser.Membership.LastActivityDate.ToString(),
nombreUsuario = myDnnUser.Profile.FirstName,
apellidoUsuario = myDnnUser.Profile.LastName,
ProfilePropertyFB = myDnnUser.Profile.GetPropertyValue("Facebook"),
ProfilePropertyGO = myDnnUser.Profile.GetPropertyValue("Google"),
ProfilePropertyTW = myDnnUser.Profile.GetPropertyValue("Twitter"),
RegularExpressionFB = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(PortalSettings.PortalId, "Facebook").ValidationExpression.ToString(),
RegularExpressionTW = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(PortalSettings.PortalId, "Twitter").ValidationExpression.ToString(),
RegularExpressionGO = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(PortalSettings.PortalId, "Google").ValidationExpression.ToString()
};
return Request.CreateResponse(HttpStatusCode.OK, U1);
[catch block etc...]
If i pause debugging when try block starts, i can see myDnnUser userinfo contains the initial profileproperties, so it doesn't save profileproperties at first web service. However, the rest of parameters as profile.firstname,userinfo.Email etc are correctly saved.
Please help me.