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);
        }
Esempio n. 2
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);
        }