public ChatMessageConnection getChatMessageConnection(Chat chat, Message m) { var cConnection = (from c in db.ChatMessageConnections where c.ChatID == chat.ID && c.MessageID == m.ID select c).SingleOrDefault(); return cConnection; }
public bool AddUserToChat(Chat c, ApplicationUser toAdd) { UserChatConnection uc = new UserChatConnection(); uc.ChatID = c.ID; uc.UserID = toAdd.Id; db.UserChatConnections.Add(uc); return db.SaveChanges() != 0; }
public bool AddMessageToChat(Chat c, Message toAdd) { ChatMessageConnection cm = new ChatMessageConnection(); cm.ChatID = c.ID; cm.MessageID = toAdd.ID; db.ChatMessageConnections.Add(cm); return db.SaveChanges() != 0; }
public ActionResult CreateChat(string username) { Chat c = new Chat(); chatService.AddChat(c); ApplicationUser currentUser = accountService.getUserByName(User.Identity.Name); ApplicationUser userChatWIth = accountService.getUserByName(username); chatService.AddUserToChat(c, currentUser); chatService.AddUserToChat(c, userChatWIth); string url = this.Request.UrlReferrer.AbsoluteUri; return Redirect(url); }
public bool AddChat(Chat c) { db.Chats.Add(c); return db.SaveChanges() != 0; }
public bool RemoveChat(Chat c) { db.Chats.Remove(c); return db.SaveChanges() != 0; }
public UserChatConnection getUserChatConnection(Chat chat, ApplicationUser a) { var uConnection = (from c in db.UserChatConnections where c.ChatID == chat.ID && c.UserID == a.Id select c).SingleOrDefault(); return uConnection; }
public List<Message> GetMessagesByChat(Chat chat) { var messages = (from c in db.ChatMessageConnections where c.ChatID == chat.ID join m in db.Messages on c.MessageID equals m.ID orderby m.DateInserted descending select m).ToList(); return messages; }