コード例 #1
0
        public ActionResult SendRequest(int receiverId)
        {
            int           senderId      = personRepository.GetIdByUserIdentityEmail(User.Identity.Name);
            FriendRequest friendRequest = new FriendRequest //Skapar ny vänförfrågan
            {
                Sender     = personRepository.GetPersonById(senderId),
                SenderId   = senderId,
                Receiver   = personRepository.GetPersonById(receiverId),
                ReceiverId = receiverId,
                Accepted   = false
            };

            try
            {
                _context.Add(friendRequest);
                _context.SaveChanges();
            }
            catch (Exception)
            {
                TempData["ProcessMessage"] = "Could not send request, try again later";
                return(PartialView("Exception"));
            }
            return(RedirectToAction("Profile", "Person", new { id = receiverId }));
        }
コード例 #2
0
 public void Add <T>(ref T entity) where T : class
 {
     _context.Add(entity);
 }