コード例 #1
0
 public void CreateFriendRequest(FriendRequest fr)
 {
     using (TempDBFriendContext db = new TempDBFriendContext())
     {
         db.FriendRequests.Add(fr);
         db.SaveChanges();
     }
 }
コード例 #2
0
        public ActionResult RequestFriend(User user, string name)
        {
            FriendRequest fr = new FriendRequest();
            fr.Receiver = name;
            fr.Sender = user.UserName;
            IDAL DAL = new DBDataAL();
            DAL.CreateFriendRequest(fr);

            FriendData data = new FriendData("matt");
            return View("Web/Friends", data);
        }
コード例 #3
0
        public ActionResult RequestFriend(string name)
        {
            string currentUser = User.Identity.Name;

            IDAL DAL = new DBDataAL();
            User user = DAL.GetUser(name);
            try
            {
                FriendRequest requests = DAL.GetFriendRequests(user).Where(x => x.Sender == currentUser).First();
            }
            catch(Exception) //if null catch explosion
            {
                FriendRequest fr = new FriendRequest();
                fr.Receiver = name;
                fr.Sender = currentUser;
                DAL.CreateFriendRequest(fr);
            }

            FriendData data = new FriendData(currentUser);

            return View("~/Views/Web/Friends.cshtml", data);
        }
コード例 #4
0
ファイル: DBDataAL.cs プロジェクト: Siryu/MathewsMages
 public void RemoveFriendRequest(FriendRequest fr)
 {
     using (TempDBFriendContext db = new TempDBFriendContext())
     {
         FriendRequest request = db.FriendRequests.Where(x => x.Receiver == fr.Receiver && x.Sender == fr.Sender).First();
         db.FriendRequests.Remove(request);
         db.SaveChanges();
     }
 }