private void AddPrivateMessageinCache(string fromEmail, string chatToEmail, string userName, string message) { using (SignalREntities dc = new SignalREntities()) { // Save master var master = dc.tblChatPrivateMessageMasters.ToList().Where(a => a.EmailID.Equals(fromEmail)).ToList(); if (master.Count == 0) { var result = new tblChatPrivateMessageMaster { EmailID = fromEmail, UserName = userName }; dc.tblChatPrivateMessageMasters.Add(result); dc.SaveChanges(); } // Save details var resultDetails = new tblChatPrivateMessageDetail { MasterEmailID = fromEmail, ChatToEmailID = chatToEmail, Message = message }; dc.tblChatPrivateMessageDetails.Add(resultDetails); dc.SaveChanges(); } }
public ActionResult Create([Bind(Include = "ID,CampaignName,Date,Clicks,Impressions,AffiliateName")] DevTest devTest) { if (ModelState.IsValid) { db.DevTests.Add(devTest); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(devTest)); }
public void AddComment(string Comment) { var Context = new SignalREntities(); Comment com = new Comment(); com.Comment1 = Comment; Context.Comments.Add(com); Context.SaveChanges(); Clients.All.AddNewComment(Comment); }
public void Connect(string userName, string userEmail) { // emailIDLoaded = userEmail; var id = Context.ConnectionId; using (SignalREntities dc = new SignalREntities()) { var item = dc.tblChatUserDetails.FirstOrDefault(x => x.EmailID == userEmail); if (item != null) { dc.tblChatUserDetails.Remove(item); dc.SaveChanges(); // Disconnect Clients.All.onUserDisconnectedExisting(item.ConnectionId, item.UserName); } var Users = dc.tblChatUserDetails.ToList(); if (Users.Where(x => x.EmailID == userEmail).ToList().Count == 0) { var userdetails = new tblChatUserDetail { ConnectionId = id, UserName = userName, EmailID = userEmail }; dc.tblChatUserDetails.Add(userdetails); dc.SaveChanges(); // send to caller var connectedUsers = dc.tblChatUserDetails.ToList(); var CurrentMessage = dc.tblChatMessageDetails.ToList(); Clients.Caller.onConnected(id, userName, connectedUsers, CurrentMessage); } // send to all except caller client Clients.AllExcept(id).onNewUserConnected(id, userName, userEmail); } }
private void AddAllMessageinCache(string userName, string message) { using (SignalREntities dc = new SignalREntities()) { var messageDetail = new tblChatMessageDetail { UserName = userName, Message = message, EmailID = emailIDLoaded }; dc.tblChatMessageDetails.Add(messageDetail); dc.SaveChanges(); } }
public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled) { using (SignalREntities dc = new SignalREntities()) { var item = dc.tblChatUserDetails.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId); if (item != null) { dc.tblChatUserDetails.Remove(item); dc.SaveChanges(); var id = Context.ConnectionId; Clients.All.onUserDisconnected(id, item.UserName); } } return(base.OnDisconnected(stopCalled)); }