예제 #1
0
        private void AddOptions(IEnumerable <List <string> > options)
        {
            var header = new List <string>
            {
                Resources.Models.Events.Events.Option,
                Resources.Models.Events.Events.Count
            };

            _excelBuilder.AddNewWorksheet(EventsConstants.EventOptionsExcelTableName, header, options);
        }
예제 #2
0
        public async Task <byte[]> ExportParticipantsAsync(int lotteryId, UserAndOrganizationDto userAndOrg)
        {
            var participants = await _participantService.GetParticipantsCountedAsync(lotteryId);

            var numberOfTicketsAdded = 0;
            var participantTickets   = new List <string>();
            var tickets = new List <List <string> >();

            foreach (var participant in participants)
            {
                for (var i = 0; i < participant.Tickets; i++)
                {
                    participantTickets.Add(participant.FullName);

                    numberOfTicketsAdded++;

                    if (numberOfTicketsAdded % BusinessLayerConstants.LotteryParticipantsInRow == 0)
                    {
                        tickets.Add(participantTickets);
                        participantTickets = new List <string>();
                    }
                }
            }

            tickets.Add(participantTickets);
            _excelBuilder.AddNewWorksheet(BusinessLayerConstants.LotteryParticipantsExcelTableName, tickets);

            return(_excelBuilder.GenerateByteArray());
        }
예제 #3
0
        public byte[] ExportToExcel(KudosLogsFilterDTO filter)
        {
            var kudosLogs = _kudosLogsDbSet
                .Include(log => log.Employee)
                .Where(log =>
                    log.OrganizationId == filter.OrganizationId &&
                    log.KudosBasketId == null)
                .Where(KudosServiceHelper.StatusFilter(filter.Status))
                .Where(KudosServiceHelper.UserFilter(filter.SearchUserId))
                .GroupJoin(_userDbSet, log => log.CreatedBy, u => u.Id, KudosServiceHelper.MapKudosLogsToDto())
                .OrderBy(string.Concat(filter.SortBy, " ", filter.SortOrder))
                .AsEnumerable()
                .Select(x => new List<object>
                {
                    x.Sender.FullName,
                    x.Receiver.FullName,
                    x.Type.Name,
                    x.Multiplier,
                    x.Points,
                    x.Created,
                    x.Comment,
                    x.Status,
                    x.Type.Value,
                    x.RejectionMessage
                });

            var header = new List<string>
            {
                Resources.Models.Kudos.Kudos.ExportColumnSender,
                Resources.Models.Kudos.Kudos.ExportColumnReceiver,
                Resources.Models.Kudos.Kudos.ExportColumnKudosType,
                Resources.Models.Kudos.Kudos.ExportColumnMultiplyBy,
                Resources.Models.Kudos.Kudos.ExportColumnPointsInTotal,
                Resources.Models.Kudos.Kudos.ExportColumnCreated,
                Resources.Models.Kudos.Kudos.ExportColumnComment,
                Resources.Models.Kudos.Kudos.ExportColumnStatus,
                Resources.Models.Kudos.Kudos.ExportColumnKudosTypeValue,
                Resources.Models.Kudos.Kudos.ExportColumnRejectionMessage
            };

            _excelBuilder.AddNewWorksheet(
                ConstBusinessLayer.KudosLogExcelSheetName,
                header,
                kudosLogs);

            return _excelBuilder.GenerateByteArray();
        }
        public async Task<byte[]> ExportToExcelAsync(UserAndOrganizationDto userAndOrg, Expression<Func<ServiceRequest, bool>> filter)
        {
            var query = _serviceRequestsDbSet
                .Include(x => x.Status)
                .Include(x => x.Priority)
                .Include(x => x.Employee)
                .Where(x => x.OrganizationId == userAndOrg.OrganizationId);

            if (filter != null)
            {
                query = query.Where(filter);
            }

            var serviceRequests = (await query.OrderByDescending(x => x.Created).ToListAsync())
                .Select(x => new List<object>
                {
                    x.Title,
                    x.Description,
                    x.CategoryName,
                    x.Status?.Title,
                    x.Priority?.Title,
                    x.Employee?.FullName,
                    x.KudosAmmount,
                    x.KudosShopItem?.Name,
                    x.Created,
                    x.Modified
                });

            var header = new List<string>
            {
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameTitle,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameDescription,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameCategory,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameStatus,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNamePriority,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameUser,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameKudosAmount,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameKudosShopItem,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameDate,
                Resources.Models.ServiceRequest.ServiceRequest.ExportColumnNameModified
            };

            _excelBuilder.AddNewWorksheet(ServiceRequestConstants.ServiceRequestsExcelSheetName, header, serviceRequests);

            return _excelBuilder.GenerateByteArray();
        }