예제 #1
0
        public ActionResult PostLike(int id)
        {
            var user = SessionSet <User> .Get("Login");

            var postUserID = _br.Query <Post>().Where(k => k.ID == id).FirstOrDefault().UserID;

            if (!_brLike.Query <Like>().Where(k => k.PostID == id && k.LikeUserID == user.ID).Any())
            {
                Like addLike = new Like()
                {
                    LikeUserID = user.ID,
                    PostID     = id
                };
                _brLike.AddModel(addLike);
                Notification notify = new Notification()
                {
                    UserID      = user.ID,
                    ActionID    = 2,
                    PostUserID  = postUserID,
                    IsShow      = true,
                    NotifyText  = user.Name + " liked your post.",
                    CreatedDate = DateTime.Now
                };
                _db.Notifications.Add(notify);
                _db.SaveChanges();
            }
            else
            {
                var delLike = _brLike.Query <Like>().Where(k => k.PostID == id && k.LikeUserID == user.ID).FirstOrDefault();
                _db.Entry(delLike).State = EntityState.Deleted;
                _db.SaveChanges();
            }

            return(RedirectToAction("Home", "Home"));
        }
예제 #2
0
        public ActionResult AddFriend(int id)
        {
            var user = SessionSet <User> .Get("Login");

            RelationShip rs = new RelationShip()
            {
                User1ID      = user.ID,
                User2ID      = id,
                CreatedDate  = DateTime.Now,
                ActionUserID = user.ID,
                StatusID     = 1
            };

            _br.AddModel(rs);
            Notification notify = new Notification()
            {
                UserID      = user.ID,
                ActionID    = 1,
                PostUserID  = id,
                IsShow      = true,
                NotifyText  = user.Name + " wants to add you as a friend.",
                CreatedDate = DateTime.Now
            };

            _db.Notifications.Add(notify);
            _db.SaveChanges();

            return(RedirectToAction("Home", "Home"));
        }
예제 #3
0
        public ActionResult AddPost(Post post)
        {
            var userID = SessionSet <User> .Get("Login").ID;

            post.CreatedDate = DateTime.Now;
            post.UserID      = userID;
            _br.AddModel(post);

            return(RedirectToAction("Home", "Home"));
        }
예제 #4
0
        public ActionResult AddTweet(Tweet tweet)
        {
            var user = SessionSet <User> .Get("Login");

            tweet.UserID      = user.ID;
            tweet.ParentID    = 0;
            tweet.CreatedDate = DateTime.Now;
            _br.AddModel(tweet);
            return(RedirectToAction("Home", "Home"));
        }
예제 #5
0
        public ActionResult SignUp(User user)
        {
            var email  = user.Email;
            var result = _br.Query <User>().Where(k => k.Email.Equals(email)).Any();

            if (!result)
            {
                user.CreatedDate = DateTime.Now;
                _br.AddModel(user);
            }
            return(RedirectToAction("Start", "Home"));
        }
예제 #6
0
        public ActionResult SignUp(User user)
        {
            var userName = user.UserName;
            var mail     = user.Email;

            user.CreatedDate = DateTime.Now;
            bool result = _br.Query <User>().Where(k => (k.UserName.Equals(userName)) && (k.Email.Equals(mail))).Any();

            if (!result)
            {
                _br.AddModel(user);
            }
            else
            {
                ModelState.AddModelError("", "Please try a different username and email.");
            }
            return(RedirectToAction("Starting", "Home"));
        }
예제 #7
0
        public ActionResult AddComment(Comment comm, int id)
        {
            var user = SessionSet <User> .Get("Login");

            comm.PostID        = id;
            comm.CreatedDate   = DateTime.Now;
            comm.CommentUserID = user.ID;
            _br.AddModel(comm);
            var          postUserID = _br.Query <Post>().Where(k => k.ID == id).FirstOrDefault().UserID;
            Notification notify     = new Notification()
            {
                UserID      = user.ID,
                ActionID    = 2,
                PostUserID  = postUserID,
                IsShow      = true,
                NotifyText  = user.Name + " commented on a post.",
                CreatedDate = DateTime.Now
            };

            _db.Notifications.Add(notify);
            _db.SaveChanges();
            return(RedirectToAction("Home", "Home"));
        }