public ActionResult Accept(string name) { if (Membership.GetUser(name) == null) return View(); Friendship friendship = new Friendship(); friendship.User = (Guid)Membership.GetUser().ProviderUserKey; friendship.UserFriend = (Guid)Membership.GetUser(name).ProviderUserKey; db.Friendships.Add(friendship); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Create(AddingFriend friend) { if (Membership.GetUser(friend.UserFriend) != null) { Friendship fs = new Friendship(); fs.User = (Guid)Membership.GetUser().ProviderUserKey; fs.UserFriend = (Guid)Membership.GetUser(friend.UserFriend).ProviderUserKey; db.Friendships.Add(fs); db.SaveChanges(); } return RedirectToAction("Index"); }