/// <summary>
 /// Create a new FriendRequest object.
 /// </summary>
 /// <param name="adderId">Initial value of the AdderId property.</param>
 /// <param name="addedId">Initial value of the AddedId property.</param>
 public static FriendRequest CreateFriendRequest(global::System.Int32 adderId, global::System.Int32 addedId)
 {
     FriendRequest friendRequest = new FriendRequest();
     friendRequest.AdderId = adderId;
     friendRequest.AddedId = addedId;
     return friendRequest;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the FriendRequests EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFriendRequests(FriendRequest friendRequest)
 {
     base.AddObject("FriendRequests", friendRequest);
 }
        public bool CreateFriendRequest(CreateFriendRequestModel aafm)
        {
            UserProfile added = db.UserProfiles.Where(u => u.UserProfileId == aafm.AddedUserProfileId).FirstOrDefault();
            UserProfile adder = db.UserProfiles.Where(u => u.UserProfileId == aafm.AdderUserProfileId).FirstOrDefault();

            if ((adder != null && added != null) && (adder != added))
            {
                if (!Utilities.HasPendingFriendRequest(adder, added) && !Utilities.HasPendingFriendRequest(added, adder) && !Utilities.AreFriends(adder, added))
                {
                    FriendRequest friendRequest = new FriendRequest();
                    friendRequest.AddingParty = adder;
                    friendRequest.AddedParty = added;

                    db.AddToFriendRequests(friendRequest);
                    db.SaveChanges();

                    return true;
                }/* I don't like this part anymore.
                else if (Utilities.HasPendingFriendRequest(added, adder) && !Utilities.AreFriends(adder, added))
                {
                    return ConfirmFriendRequest(new FriendRequestModel { AdderUserProfileId = adder.UserProfileId, AddedUserProfileId = added.UserProfileId });
                }*/
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }