Esempio n. 1
0
        public async Task JoinAtSessionAsync(AttendeeVO newAttendee)
        {
            if (!(await _sessionBusiness.FindBySessionReferenceTaskAsync(newAttendee.SessionReference) is SessionVO session))
            {
                await Clients.Caller.NotExistsThisSessionAsync("Nao existe uma sessao com esse nome!");

                return;
            }

            if (await _attendeeBusiness.FindByNameInSessionTaskAsync(newAttendee) is AttendeeVO)
            {
                await Clients.Caller.NotExistsAttendeeWithThisNameAsync("Ja existe um participante com este nome!");

                return;
            }

            if (!(await _attendeeBusiness.JoinAtSessionTaskAsync(newAttendee) is AttendeeVO joinedAttendee))
            {
                await Clients.Caller.NotJoinedAtSessionAsync("Nao foi possivel participar da sessao, tente novamente!");

                return;
            }

            await Clients.Caller.JoinedAtSessionAsync(joinedAttendee, session, "Agora voce está participando da sessao!");

            await Clients.OthersInGroup(joinedAttendee.SessionReference).AttendeeJoinedAsync(joinedAttendee, $"{joinedAttendee.Name} agora está participando da sessao!");

            await Groups.AddToGroupAsync(Context.ConnectionId, session.SessionReference);
        }
Esempio n. 2
0
        public async Task LeaveAtSessionAsync(AttendeeVO attendee)
        {
            AttendeeModel attendeeModel = _attendeeConverter.Parse(attendee);

            if (!(await _attendeeRepository.FindByIdInSessionTaskAsync(attendeeModel) is AttendeeModel currentAttendee))
            {
                throw new Exception("Nao foi possivel pegar as informaçoes do participante");
            }

            await _attendeeRepository.LeaveAttendeeTaskAsync(currentAttendee);
        }
Esempio n. 3
0
        public async Task <AttendeeVO> JoinAtSessionTaskAsync(AttendeeVO newAttendee)
        {
            AttendeeModel newAttendeeModel = _attendeeConverter.Parse(newAttendee);

            if (!(await _attendeeRepository.AddAttendeeTaskAsync(newAttendeeModel) is AttendeeModel addedAttendeeModel))
            {
                throw new Exception("Nao foi possivel adicionar o participante na sessao");
            }

            return(_attendeeConverter.Parse(addedAttendeeModel));
        }
Esempio n. 4
0
        public async Task LeaveAtSessionAsync(AttendeeVO attendee)
        {
            if (!(await _sessionBusiness.FindBySessionReferenceTaskAsync(attendee.SessionReference) is SessionVO))
            {
                await Clients.Caller.NotExistsThisSessionAsync("Nao existe uma sessao com esse nome!");

                return;
            }

            if (!(await _attendeeBusiness.FindByNameInSessionTaskAsync(attendee) is AttendeeVO currentAttendee))
            {
                await Clients.Caller.NotExistsAttendeeWithThisNameAsync("Nao existe nenhum participante na sessao com este nome!");

                return;
            }

            await _attendeeBusiness.LeaveAtSessionAsync(currentAttendee);

            await Clients.Caller.ExitedAtSessionAsync("Voce deixou a sessao!");

            await Clients.OthersInGroup(currentAttendee.SessionReference).AttendeeExitedAsync(currentAttendee, $"{currentAttendee.Name} deixou a sessao!");

            await Groups.RemoveFromGroupAsync(Context.ConnectionId, currentAttendee.SessionReference);
        }
Esempio n. 5
0
        public async Task <AttendeeVO> FindByNameInSessionTaskAsync(AttendeeVO attendee)
        {
            AttendeeModel attendeeModel = _attendeeConverter.Parse(attendee);

            return(_attendeeConverter.Parse(await _attendeeRepository.FindByNameInSessionTaskAsync(attendeeModel)));
        }