Пример #1
0
 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;
 }
Пример #2
0
 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;
 }
Пример #3
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;
 }
Пример #4
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);
        }
Пример #5
0
 public bool AddChat(Chat c)
 {
     db.Chats.Add(c);
     return db.SaveChanges() != 0;
 }
Пример #6
0
 public bool RemoveChat(Chat c)
 {
     db.Chats.Remove(c);
     return db.SaveChanges() != 0;
 }
Пример #7
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;
 }
Пример #8
0
 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;
 }