Exemplo n.º 1
0
        public override async Task OnConnectedAsync()
        {
            await base.OnConnectedAsync();

            UpdateConnectionId();
            await ReportActivity();

            var participant = new Participant
            {
                UserId       = Context.UserIdentifier,
                UserName     = Context.User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value).Single(),
                ConnectionId = Context.ConnectionId,
                Vote         = null,
                IsModerator  = false,
            };

            var oldParticipant = participantRepository.GetById(Context.UserIdentifier);

            if (oldParticipant != null)
            {
                logger.LogInformation($"Attempting reconnect: {oldParticipant.UserName}, {oldParticipant.RoomId}");
                if (!string.IsNullOrEmpty(oldParticipant.RoomId))
                {
                    await Groups.AddToGroupAsync(Context.ConnectionId, oldParticipant.RoomId);
                    await SendParticipantsStateUpdate(oldParticipant.RoomId);
                    await SendNavigationUpdate(oldParticipant.RoomId);
                    await SendRoomSettingsUpdate(oldParticipant.RoomId);
                    await SendStoryStateUpdate();
                }
            }
            else
            {
                participantRepository.Create(participant);
            }
        }
 public IActionResult Create(Participant nowyParticipant)
 {
     if (ModelState.IsValid)
     {
         Participant newemploye = _ParticipantRepository.Create(nowyParticipant);
         return(RedirectToAction("details", new { id = newemploye.Id }));
     }
     return(View());
 }
        public void AddParticapant(ParticipantDTO participantDTO)
        {
            var participant = Mapper.Map <ParticipantDTO, Participant>(participantDTO);

            repository.Create(participant);
        }