예제 #1
0
        public ActionResult DeclineRequest(Request model)
        {
            var request = context.Requests.Find(model.Id);

            request.Status = RequestStatus.Declined;
            request.StatusDateTime = DateTime.Now;

            context.SaveChanges();

            var requests = Requests();

            return PartialView("RequestsPartial", requests);
        }
예제 #2
0
        public ActionResult AcceptRequest(Request model)
        {
            var request = context.Requests.Find(model.Id);
            var sender = request.Sender;
            var receiver = request.Receiver;

            request.Status = RequestStatus.Accepted;
            request.StatusDateTime = DateTime.Now;

            sender.Friends.Add(receiver);
            receiver.Friends.Add(sender);

            context.SaveChanges();

            var requests = Requests();

            return PartialView("RequestsPartial", requests);
        }
예제 #3
0
        public ActionResult SendRequest(User model)
        {
            var currentUser = context.Users.Find(WebSecurity.CurrentUserId);
            var user = context.Users.Find(model.Id);

            var request = new Request
            {
                Sender = currentUser,
                Receiver = user,
                DateTime = DateTime.Now,
                StatusDateTime = DateTime.Now
            };

            context.Requests.Add(request);
            context.SaveChanges();

            var users = Users();

            return PartialView("UsersPartial", users);
        }