public ActionResult CreateChat(int reactionId, int volunteerId) { int userId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == System.Security.Claims.ClaimTypes.Sid).Value); int id = _chatLogic.CreateNewChatLog(reactionId, volunteerId, userId); if (id != 0) { return(RedirectToAction("OpenChat", new { id })); } return(RedirectToAction(nameof(Overview))); }
public void CreateNewChatLog_IsValid() { Mock <IChatContext> mockContext = new Mock <IChatContext>(); int newChatLogId = 3; mockContext.Setup(x => x.CreateNewChatLog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())) .Returns(newChatLogId); ChatLogic chatLogic = new ChatLogic(mockContext.Object); int result = chatLogic.CreateNewChatLog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()); mockContext.Verify(x => x.CreateNewChatLog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())); Assert.IsInstanceOfType(result, typeof(int)); Assert.AreEqual(newChatLogId, result); }
private void btnCreateChatlog_Click(object sender, EventArgs e) { if (lvQuestionReaction.SelectedItems.Count == 1) { int selectedRow = lvQuestionReaction.SelectedItems[0].Index; int selectedId = Convert.ToInt32(lvQuestionReaction.Items[selectedRow].SubItems[3].Text); int reactionID = Convert.ToInt32(lvQuestionReaction.Items[selectedRow].SubItems[4].Text); int senderID = Convert.ToInt32(lvQuestionReaction.Items[selectedRow].SubItems[5].Text); ChatLogic cl = new ChatLogic(); cl.CreateNewChatLog(reactionID, senderID, FormLogin.currentUser.UserId); MessageBox.Show("Chat aangemaakt"); ((FormMain)this.Parent.Parent).ReplaceForm(new FormCareChatOverview()); } else { MessageBox.Show("Error"); } }