Ejemplo n.º 1
0
        public static bool UpdateUserProfile(ProfileInfo profile, long userId, out string msg)
        {
            try
            {
                if (profile == null)
                {
                    msg = "Empty / Invalid Profile Object";
                    return(false);
                }
                if (userId < 1)
                {
                    msg = "Empty / Invalid Profile Object";
                    return(false);
                }
                var propertyInfos = typeof(ProfileInfo).GetProperties();
                if (!propertyInfos.Any())
                {
                    msg = "Invalid Profile Object";
                    return(false);
                }

                var user = PortalUser.GetRawUser(userId);
                if (user == null || user.UserId < 1)
                {
                    msg = "Unable to retrieve user detail information!";
                    return(false);
                }

                user.Sex          = (int)profile.Sex;
                user.FirstName    = profile.FirstName;
                user.Surname      = profile.LastName;
                user.MobileNumber = profile.MobileNo;


                var retId = PortalUser.UpdateUser(user, out msg);
                if (!retId)
                {
                    if (string.IsNullOrEmpty(msg))
                    {
                        msg = "Process Failed! Please try again later";
                    }
                    return(false);
                }

                msg = "";
                return(true);
            }
            catch (Exception ex)
            {
                msg = "Error: " + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }