Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }