示例#1
0
 public async Task <IEnumerable <AggregateUtilizationReportResponseModel> > AdminAggregateUtilization([FromRoute] int partnerId, [FromBody] AggregateUtilizationReportRequestModel filter)
 {
     return(await _logManager.AdminAggregateUtilizationAsync(partnerId, filter));
 }
示例#2
0
 public async Task <IEnumerable <LogEntity> > GetByDatesAsync(AggregateUtilizationReportRequestModel filter, ICollection <int> employeeIds)
 {
     return((await _logs.FindAsync(x => true && x.CreatedAt >= filter.StartDate && x.CreatedAt <= filter.EndDate &&
                                   (employeeIds.Contains(x.SenderId) || employeeIds.Contains(x.RecipientId)), OrderByTimeFindOptions)).ToEnumerable());
 }
示例#3
0
        public async Task <IEnumerable <AggregateUtilizationReportResponseModel> > AdminAggregateUtilizationAsync(int partnerId, AggregateUtilizationReportRequestModel filter)
        {
            var filteremployees = await _contactRepository.GetChatUsersAsync(filter.EmployeeIds, partnerId);

            var employeeIds = filteremployees.AsQueryable().Select(x => x.ChatUserId).ToList();
            var logs        = (await _logRepository.GetByDatesAsync(filter, employeeIds)).ToList();
            var results     = new List <AggregateUtilizationReportResponseModel>();

            foreach (int employeeId in employeeIds)
            {
                var item              = new AggregateUtilizationReportResponseModel();
                var filterSentLog     = logs.Where(x => x.SenderId == employeeId).ToList();
                var filterReceivedLog = logs.Where(x => x.RecipientId == employeeId).ToList();
                if ((filterSentLog == null || filterSentLog.Count == 0) && (filterReceivedLog == null || filterReceivedLog.Count == 0))
                {
                    continue;
                }

                if (filterSentLog == null || filterSentLog.Count == 0)
                {
                    item.EmployeeName          = filterReceivedLog[0].RecepientName;
                    item.TotalSentMessages     = 0;
                    item.TotalReceivedMessages = filterReceivedLog.Count;
                }
                else if (filterReceivedLog == null || filterReceivedLog.Count == 0)
                {
                    item.EmployeeName          = filterSentLog[0].SenderName;
                    item.TotalReceivedMessages = 0;
                    item.TotalSentMessages     = filterSentLog.Count;
                }
                else
                {
                    item.EmployeeName          = filterSentLog[0].SenderName;
                    item.TotalSentMessages     = filterSentLog.Count;
                    item.TotalReceivedMessages = filterReceivedLog.Count;
                }
                results.Add(item);
            }
            return(results);
        }