示例#1
0
        private ProfileInfo GetProfileInfoFromProfile(Profile p)
        {
            var user = users.Get(p.Users_Id);
            if (user == null)
                throw new ProviderException("The userid not found in memebership tables.GetProfileInfoFromProfile(p)");

            // ProfileInfo.Size not currently implemented.
            var pi = new ProfileInfo(user.Username,
                p.IsAnonymous, p.LastActivityDate, p.LastUpdatedDate, 0);
            return pi;
        }
示例#2
0
 private Profile CreateProfile(string username, bool isAnonymous)
 {
     var profile = new Profile();
     var profileCreated = false;
     try {
         var user = users.GetUserByUsername(ApplicationName, username);
         if (user != null) {
             profile.Users_Id = user.Id;
             profile.IsAnonymous = isAnonymous;
             profile.LastUpdatedDate = DateTime.Now;
             profile.LastActivityDate = DateTime.Now;
             profile.ApplicationName = ApplicationName;
             profiles.Update(profile);
             profiles.SaveChanges();
             profileCreated = true;
         } else
             throw new ProviderException("Membership User does not exist.Profile cannot be created.");
     } catch (Exception ex) {
         if (WriteExceptionsToEventLog)
             WriteToEventLog(ex, "GetProfile");
         else
             throw;
     }
     return profileCreated ? profile : null;
 }