public ActionResult AddRecipient(int threadID, int recipientID) { var entity = SessionHelper.CurrentEntity; var thread = messageRepository.Where((MessageThread t) => t.ID == threadID).FirstOrDefault(); if (thread == null) { return(RedirectToHomeWithError("Thread does not exist!")); } if (messageService.IsMemberOfThread(entity, thread) == false) { return(RedirectToHomeWithError("You cannot do that!")); } var newEntity = entityRepository.GetById(recipientID); if (newEntity == null) { return(RedirectToHomeWithError("Recipient does not exist!")); } messageService.AddRecipient(newEntity, thread); AddSuccess($"Successfully added {newEntity.Name}"); return(RedirectBack()); }