public void AddChatRoomToDatabase() { // Arrange ChatRoom room = new ChatRoom() { ChatRoomName = "ASDFE", HasAdminUser = true, Status = 1 }; // Act _service.AddChatRoom(room); var rooms = _service.GetActiveChatRooms(); // Assert Assert.IsNotNull(rooms); }
// Connect/Create Agent ChatUser and add to a ChatRoom and SignalR Group public ChatClientUser ConnectUser(string username) { var OnlineUsers = _service.GetOnlineUsers(); if (OnlineUsers.Count() > 1) { string roomName = RandomString(5); JoinGroup(roomName); ChatClientUser user = new ChatClientUser() { userName = username, roomName = roomName, isUserAllowed = true, ConnectionId = Context.ConnectionId }; ChatRoom room = new ChatRoom(); room.ChatUserId = user.userName; room.StartTime = GetLocalTime(); //room.StartTime = DateTime.Now; room.Status = 0; room.ActiveUserCount = 1; room.ChatRoomName = roomName; room.HasAdminUser = false; activeUsers.Add(user); // Save ChatRoom to Repo _service.AddChatRoom(room); // This adds the new chat room to the admin chat lobby Clients.Group("adminGroup").addActiveRoom(room, user); RoomFeedVM roomFeed = new RoomFeedVM(); if (room.HasAdminUser == true) { roomFeed.BeingHelped = "Yes"; } else { roomFeed.BeingHelped = "No"; } roomFeed.ClientId = room.ChatUserId; roomFeed.HelperName = ""; roomFeed.RoomName = room.ChatRoomName; roomFeed.StartTime = room.StartTime; roomFeed.UsersInRoom = room.ActiveUserCount; Clients.All.addRoom(roomFeed); return user; } else { return new ChatClientUser { userName = username, isUserAllowed = false }; } }
public void AddChatRoom(ChatRoom room) { _repo.AddNewChatRoom(room); }
public void UpdateChatRoom(ChatRoom room) { _repo.UpdateChatRoom(room); }
public void AddNewChatRoom(ChatRoom room) { _dbContext.ChatRooms.Add(room); _dbContext.SaveChanges(); }
public void UpdateChatRoom(ChatRoom room) { _dbContext.Entry(room).State = EntityState.Modified; _dbContext.SaveChanges(); }