コード例 #1
0
 /// <summary>
 /// Create a new UserProfile object.
 /// </summary>
 /// <param name="userProfileId">Initial value of the UserProfileId property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="birthdate">Initial value of the Birthdate property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="reputation">Initial value of the Reputation property.</param>
 /// <param name="timezone">Initial value of the Timezone property.</param>
 /// <param name="isFemale">Initial value of the IsFemale property.</param>
 public static UserProfile CreateUserProfile(global::System.Int32 userProfileId, global::System.String firstName, global::System.String lastName, global::System.DateTime birthdate, global::System.String description, global::System.Int32 reputation, global::System.Int32 timezone, global::System.Boolean isFemale)
 {
     UserProfile userProfile = new UserProfile();
     userProfile.UserProfileId = userProfileId;
     userProfile.FirstName = firstName;
     userProfile.LastName = lastName;
     userProfile.Birthdate = birthdate;
     userProfile.Description = description;
     userProfile.Reputation = reputation;
     userProfile.Timezone = timezone;
     userProfile.IsFemale = isFemale;
     return userProfile;
 }
コード例 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserProfiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserProfiles(UserProfile userProfile)
 {
     base.AddObject("UserProfiles", userProfile);
 }
コード例 #3
0
        public bool CreateUser(CreateUserModel userModel, CreateUserProfileModel userProfileModel)
        {
            User user = new User();
            user.Username = userModel.Username;
            user.Password = userModel.Password;
            user.Email = userModel.Email;

            user.PasswordSalt = "abc123";
            user.AlternateEmail = "";
            user.LastModifiedDate = DateTime.Now;
            user.LastLoginDate = DateTime.Now;
            user.CreatedDate = DateTime.Now;
            user.IsActivated = true;
            user.IsLockedOut = false;
            user.LastLockedOutDate = DateTime.Now;
            user.SecurityQuestion = "";
            user.SecurityAnswer = "";

            UserProfile userProfile = new UserProfile();
            userProfile.FirstName = userProfileModel.FirstName;
            userProfile.LastName = userProfileModel.LastName;
            userProfile.Birthdate = userProfileModel.Birthdate;
            userProfile.IsFemale = userProfileModel.IsFemale;
            userProfile.Description = userProfileModel.Description;
            userProfile.Avatar = "/Content/Images/viewprofile.png";

            userProfile.Reputation = 0;

            user.UserProfile = userProfile;

            db.AddToUsers(user);
            db.SaveChanges();

            return true;
        }
コード例 #4
0
        public static bool AreFriends(UserProfile a, UserProfile b)
        {
            IEnumerable<Friendship> test = a.RequestedFriendships.Where(x => x.AddedId == b.UserProfileId).Union(b.RequestedFriendships.Where(y => y.AddedId == a.UserProfileId));

            return test.Count() != 0;
        }
コード例 #5
0
        public static UserProfileModel UserProfileToUserProfileModel(UserProfile userProfile)
        {
            if (userProfile != null)
            {
                UserProfileModel userProfileModel = new UserProfileModel();
                userProfileModel.UserProfileId = userProfile.UserProfileId;
                userProfileModel.FirstName = userProfile.FirstName;
                userProfileModel.LastName = userProfile.LastName;
                userProfileModel.IsFemale = userProfile.IsFemale;
                userProfileModel.Description = userProfile.Description;
                userProfileModel.AcceptedFriendships = userProfile.AcceptedFriendships;
                userProfileModel.RequestedFriendships = userProfile.RequestedFriendships;
                userProfileModel.Birthdate = userProfile.Birthdate;
                userProfileModel.Comments = userProfile.Comments;
                userProfileModel.Reputation = userProfile.Reputation;
                userProfileModel.Avatar = userProfile.Avatar;
                userProfileModel.PendingFriendRequests = userProfile.PendingFriendRequests;
                userProfileModel.RequestedFriendRequests = userProfile.RequestedFriendRequests;

                return userProfileModel;
            }
            else
            {
                return null;
            }
        }
コード例 #6
0
        public static bool HasPendingFriendRequest(UserProfile adder, UserProfile added)
        {
            IEnumerable<FriendRequest> test = added.PendingFriendRequests.Where(x => x.AdderId == adder.UserProfileId);
            //IEnumerable<FriendRequest> test2 = adder.PendingFriendRequests.Where(x => x.AdderId == added.UserProfileId);

            return (test/*.Union(test2)*/).Count() != 0;
        }