Example #1
0
        public void AddUserByNameToChat(string username, int idChat)
        {
            ChatMembership membership = new ChatMembership();

            var u = (from user in this._context.ChatUser
                     where user.UserName == username
                     select user).FirstOrDefault();

            membership.IdUser_ChatUser = u.IdUser;
            membership.IdChat_Chat = idChat;

            this._context.ChatMembership.Add(membership);
            this._context.SaveChanges();
        }
Example #2
0
        public void AddUserToChat(ChatUser user, int idChat)
        {
            ChatMembership membership = new ChatMembership();

            membership.IdUser_ChatUser = user.IdUser;
            membership.IdChat_Chat = idChat;

            this._context.ChatMembership.Add(membership);
            this._context.SaveChanges();
        }