public virtual ActionResult SendMessage(Guid Id, string Contents) { ChatMessage sent; using (IWriteContext writeContext = ChatMessageRepository.WriteContext()) { ChatSession target = this.ChatSessionRepository.Find(Id); if (target is null) { throw new UnauthorizedAccessException(); } if (!string.IsNullOrWhiteSpace(Contents)) { sent = this.ChatMessageRepository.SendMessageToChat(target, this.UserSession.LoggedInUser, Contents); return(this.View("ViewMessage", sent)); } } throw new Exception("An error occurred sending the message"); }