Last active
August 29, 2015 14:00
-
-
Save dwatts1772/11356324 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User | |
{ | |
public User(){ | |
Friends = new List<FriendInfo>(); | |
} | |
[Key] | |
public int UserId { get; set; } | |
[Required] | |
public string EmailAddress { get; set; } | |
public DateTime? DateOfBirth { get; set; } | |
public DateTime? LastLoginDate { get; set; } | |
public DateTime? LastRefreshDate { get; set; } | |
public virtual ICollection<FriendInfo> Friends { get; set; } | |
} | |
public class FriendInfo | |
{ | |
public FriendInfo() | |
{ | |
Users = new List<User>(); | |
} | |
[Key] | |
public int FriendInfoId { get; set; } | |
public FRIEND_STATUS Status { get; set; } | |
[Required] | |
public DateTime Expires { get; set; } | |
public DateTime? DateAccepted { get; set; } | |
public DateTime? DateRequested { get; set; } | |
public virtual ICollection<User> Users { get; set; } | |
} | |
} | |
public FriendInfo CreateFriend(int friendId){ | |
User user = _userRepo.FindByEmail(HttpContext.Current.User.Identity.Name); | |
User friend = _userRepo.Find(friendId); | |
var users = new List<User>(); | |
_userRepo.InsertOrUpdate(user); | |
_userRepo.InsertOrUpdate(friend); | |
users.Add(user); | |
users.Add(friend); | |
//Create Friend | |
FriendInfo friendInfo = new FriendInfo | |
{ | |
//UserId = userId, | |
//FriendId = friend.UserId, | |
Users = users, | |
Status = FriendInfo.FRIEND_STATUS.UNAPPROVED, | |
}; | |
try | |
{ | |
_friendinfoRepo.InsertOrUpdate(friendInfo); | |
await _friendinfoRepo.SaveAsync(); | |
} | |
catch (Exception ex) | |
{ | |
throw ex; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment