Пример #1
0
        public async Task <EventUserDTO> GetCreatedArchivedEvents(string userId, ClaimsPrincipal user)
        {
            var currentUserId = _userManager.GetUserId(user);

            if (string.IsNullOrEmpty(userId))
            {
                userId = currentUserId;
            }

            var targetUser = await _repoWrapper.User.GetFirstAsync(predicate : q => q.Id == userId);

            var model = new EventUserDTO
            {
                User = _mapper.Map <User, UserDTO>(targetUser)
            };

            var eventAdmins = await _eventAdmininistrationManager.GetEventAdmininistrationByUserIdAsync(userId);

            model.CreatedEvents = new List <EventGeneralInfoDTO>();
            foreach (var eventAdmin in eventAdmins)
            {
                var eventToAdd = _mapper.Map <Event, EventGeneralInfoDTO>(eventAdmin.Event);
                if (!(eventToAdd.EventDateEnd > DateTime.Now))
                {
                    eventToAdd.EventStatusID = 1;
                    model.CreatedEvents.Add(eventToAdd);
                }
            }

            return(model);
        }
Пример #2
0
        public async Task <EventUserDTO> EventUserAsync(string userId, ClaimsPrincipal user)
        {
            var currentUserId = _userManager.GetUserId(user);

            if (string.IsNullOrEmpty(userId))
            {
                userId = currentUserId;
            }

            var targetUser = await _repoWrapper.User.GetFirstAsync(predicate : q => q.Id == userId);

            User userWithRoles = await _userManager.FindByIdAsync(userId);

            var userRoles = await _userManager.GetRolesAsync(userWithRoles);

            var model = new EventUserDTO
            {
                User      = _mapper.Map <User, UserDTO>(targetUser),
                UserRoles = userRoles
            };
            var eventAdmins = await _eventAdmininistrationManager.GetEventAdmininistrationByUserIdAsync(userId);

            var participants = await _participantManager.GetParticipantsByUserIdAsync(userId);

            model.CreatedEvents = new List <EventGeneralInfoDTO>();
            foreach (var eventAdmin in eventAdmins)
            {
                var eventToAdd = _mapper.Map <Event, EventGeneralInfoDTO>(eventAdmin.Event);
                if (eventToAdd.EventDateEnd > DateTime.Now)
                {
                    model.CreatedEvents.Add(eventToAdd);
                }
            }

            model.PlanedEvents  = new List <EventGeneralInfoDTO>();
            model.VisitedEvents = new List <EventGeneralInfoDTO>();
            foreach (var participant in participants)
            {
                var eventToAdd = _mapper.Map <Event, EventGeneralInfoDTO>(participant.Event);
                if (participant.Event.EventDateEnd >= DateTime.Now)
                {
                    model.PlanedEvents.Add(eventToAdd);
                }
                else if (participant.Event.EventDateEnd < DateTime.Now &&
                         participant.ParticipantStatusId == await _participantStatusManager.GetStatusIdAsync("Учасник"))
                {
                    model.VisitedEvents.Add(eventToAdd);
                }
            }

            return(model);
        }
Пример #3
0
 public void RemoveUser(EventUserDTO user, int eventId)
 {
     _context.Clients.All.removeUser(user.Name, user.UserID, eventId.ToString());
 }