public ActionResult InsertMensaje(Mensajes model) { model.ToString(); model.FechaCreacion = DateTime.Now; if (ModelState.IsValid) { using (var context = new ApplicationDbContext()) { context.Mensajes.Add(model); Conversacion conversacion = new Conversacion { ApplicationUserId = model.UsuarioRecibe, MensajeId = model.MensajeId }; context.Conversaciones.Add(conversacion); context.SaveChanges(); } } ChatHub.NotifyCurrentEmployeeInformationToAllClients(); return(RedirectToAction("Index")); }
public ActionResult InsertDefault(Mensajes model) { //model.ToString(); model.FechaCreacion = DateTime.Now; if (ModelState.IsValid) { //Insert into Message table using (var context = new ApplicationDbContext()) { context.Mensajes.Add(model); context.SaveChanges(); } } //Once the record is inserted , then notify all the subscribers (Clients) ChatHub.NotifyCurrentEmployeeInformationToAllClients(); return(RedirectToAction("ChatDefault")); }