Пример #1
0
        public ActionResult AcceptDecline(int FriendId, string AcceptDecline)
        {
            var UserId = _DatingContext.Profiles.SingleOrDefault(p => p.Email == User.Identity.Name).Id;
            //Hittar rätt rad i Db för att kunna uppdatera den
            var friendFound = _DatingContext.FriendRequests.FirstOrDefault
                                  (x => x.FriendReceiverId == UserId && x.FriendSenderId == FriendId);

            // Om ej null och Accept
            if (AcceptDecline == "Accept" && friendFound != null)
            {
                friendFound.Accepted = true;
                _DatingContext.SaveChanges();
            }
            // Om ej null och Decline
            else if (AcceptDecline == "Decline" && friendFound != null)
            {
                _DatingContext.Remove(friendFound);
                _DatingContext.SaveChanges();
            }
            return(RedirectToAction(nameof(Requests)));
        }
Пример #2
0
 public void Delete <T>(T entity) where T : class
 {
     _context.Remove(entity);
 }