Skip to content

Instantly share code, notes, and snippets.

@dwatts1772
Last active August 29, 2015 14:00
Show Gist options
  • Save dwatts1772/11356324 to your computer and use it in GitHub Desktop.
Save dwatts1772/11356324 to your computer and use it in GitHub Desktop.
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