public void TestEmptyGetGroupMaster()
        {
            bool result    = false;
            var  assertion = _manageHubUser.GetGroupMaster("1");

            if (assertion == null)
            {
                result = true;
            }

            Assert.True(result);
        }
Example #2
0
        public async Task <IActionResult> ManageHubUser(string roomNo)
        {
            var userMaster  = new Entities.Models.User();
            var groupMaster = _manageHubUser.GetGroupMaster(roomNo);

            if (groupMaster != null)
            {
                userMaster = _repo.User.FindByCondition(u => u.Id == groupMaster.First().UserId).FirstOrDefault();
            }

            var connectedUsers = new List <HubUserVM>();

            GenerateHubUserVM(connectedUsers, _manageHubUser.GetConnectedUsers(roomNo));

            var waitingUsers = new List <HubUserVM>();

            GenerateHubUserVM(waitingUsers, _manageHubUser.GetWaitingUsers(roomNo));

            ManageHubUserVM = new ManageHubUserViewModel()
            {
                GroupName      = roomNo,
                ConnectedUsers = connectedUsers,
                WaitingUsers   = waitingUsers,
                GroupMaster    = _mapper.Map <WebApp.Models.User>(userMaster)
            };

            return(View(ManageHubUserVM));
        }
Example #3
0
        public async Task RegisterDoctor(string roomNo)
        {
            var claimsIdentity = (ClaimsIdentity)Context.User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
            var userId         = claim.Value;

            var newUser = new HubUser {
                UserId       = claim.Value,
                ConnectionId = Context.ConnectionId,
                GroupName    = roomNo
            };

            var userInControl = _hubUser.GetGroupMaster(newUser.GroupName);

            if (userInControl == null || userInControl.FirstOrDefault().UserId == newUser.UserId)
            {
                await Groups.AddToGroupAsync(newUser.ConnectionId, newUser.GroupName);

                var user = _repo.User.FindByCondition(u => u.Id == userId).FirstOrDefault();

                string doctorFullName = QueueHelper.GetDoctorFullName(user);
                await Clients.Group(roomNo).SendAsync("ReceiveDoctorFullName", userId, doctorFullName);

                var queue = _queueService.FindByUserId(userId);
                _queueService.SetQueueActive(queue);

                await Clients.Group(roomNo).SendAsync("ReceiveQueueNo", userId, queue.QueueNoMessage);

                await Clients.Group(roomNo).SendAsync("ReceiveAdditionalInfo", userId, queue.AdditionalMessage);
            }
            else
            {
                await Clients.Caller.SendAsync("NotifyQueueOccupied", StaticDetails.QueueOccupiedMessage);
            }
            await _hubUser.AddUserAsync(newUser);

            Log.Information(String.Concat(logPrefix, "Client [ ",
                                          newUser.ConnectionId, " ] registered as Doctor for room: [ ", roomNo, " ]"));
        }