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); }
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); }
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); }