Exemplo n.º 1
0
        public ReportEventsQueryResult Handle(ReportEventsQuery query)
        {
            List <FIL.Contracts.DataModels.EventsUserMapping> assignedEvents = new List <FIL.Contracts.DataModels.EventsUserMapping>();
            List <FIL.Contracts.DataModels.Event>             events         = new List <FIL.Contracts.DataModels.Event>();
            List <Event> eventList   = new List <Event>();
            var          userDetails = _userRepository.GetByAltId(query.AltId);

            if (userDetails.RolesId == 1)
            {
                events    = _eventRepository.GetAllZoongaEvents(query.IsFeel).ToList();
                eventList = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.Event> >(events).ToList();
            }
            else
            {
                assignedEvents = _eventsUserMappingRepository.GetByUserId(userDetails.Id).ToList();
                for (int k = 0; k < assignedEvents.Count; k = k + 2000)
                {
                    var eventBatcher = assignedEvents.Skip(k).Take(2000);
                    events    = _eventRepository.GetByAllEventIds(eventBatcher.Select(s => s.EventId)).Distinct().ToList();
                    eventList = eventList.Concat(AutoMapper.Mapper.Map <List <FIL.Contracts.Models.Event> >(events)).ToList();
                }
            }
            return(new ReportEventsQueryResult
            {
                Events = AutoMapper.Mapper.Map <IEnumerable <FIL.Contracts.Models.Event> >(eventList)
            });
        }
Exemplo n.º 2
0
        public FAPGetPlacesQueryResult Handle(FAPGetPlacesQuery query)
        {
            List <FIL.Contracts.Models.TransactionReport.FAPAllPlacesResponseModel> places = new List <FIL.Contracts.Models.TransactionReport.FAPAllPlacesResponseModel>();

            try
            {
                List <long> EventIds = new List <long>(); bool isFeelAdminRole = true;
                var         user = _userRepository.GetByAltId(query.UserAltId);
                if (user.RolesId != 10)                   //if not super admin
                {
                    var createdEvents = _eventRepository.GetAllByUserAltId(query.UserAltId);
                    var userEvents    = _eventsUserMappingRepository.GetByUserId(user.Id);
                    EventIds.AddRange(createdEvents.Select(s => s.Id));
                    EventIds.AddRange(userEvents.Select(s => s.EventId));
                    isFeelAdminRole = false;
                }
                places = _reportingRepository.GetAllReportEvents(query.isFeel, EventIds, isFeelAdminRole).ToList();
                return(new FAPGetPlacesQueryResult
                {
                    Places = places
                });
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, new Exception("Failed to get places for reports", e));
                return(new FAPGetPlacesQueryResult
                {
                    Places = places
                });
            }
        }