Beispiel #1
0
 public async Task <IEnumerable <LogEntity> > GetByPartnerIdAsync(SentMessageReportRequestModel filter)
 {
     if (filter.IsImportant == null)
     {
         if (filter.EndDate == null || filter.StartDate == null)
         {
             return((await _logs.FindAsync(x => true, OrderByTimeFindOptions)).ToEnumerable());
         }
         else
         {
             return((await _logs.FindAsync(x => true && x.CreatedAt >= filter.StartDate && x.CreatedAt <= filter.EndDate, OrderByTimeFindOptions)).ToEnumerable());
         }
     }
     else
     {
         return((await _logs.FindAsync(x => true && x.IsImportant == filter.IsImportant && x.CreatedAt >= filter.StartDate && x.CreatedAt <= filter.EndDate, OrderByTimeFindOptions)).ToEnumerable());
     }
 }
Beispiel #2
0
 public async Task <IEnumerable <SentMessageReportResponseModel> > AdminSentMessages([FromRoute] int partnerId, [FromBody] SentMessageReportRequestModel filter)
 {
     return(await _logManager.AdminSentMessagesAsync(partnerId, filter));
 }
Beispiel #3
0
        public async Task <IEnumerable <SentMessageReportResponseModel> > AdminSentMessagesAsync(int partnerId, SentMessageReportRequestModel filter)
        {
            var filterSenders = await _contactRepository.GetChatUsersAsync(filter.SenderIds, partnerId);

            var senderIds        = filterSenders.AsQueryable().Select(x => x.ChatUserId).ToList();
            var filterRecepients = await _contactRepository.GetChatUsersAsync(filter.RecepientIds, partnerId);

            var recepientIds = filterRecepients.AsQueryable().Select(x => x.ChatUserId).ToList();

            if (filter.IsImportant != null)
            {
                var logs = (await _logRepository.GetAllAsync()).Where(x => senderIds.Contains(x.SenderId) && recepientIds.Contains(x.RecipientId) && x.IsImportant == filter.IsImportant);
                return(_mapper.Map <IEnumerable <Domain.ChatDomains.Entity.LogEntity>, IEnumerable <SentMessageReportResponseModel> >(logs));
            }
            else
            {
                var logs = (await _logRepository.GetAllAsync()).Where(x => senderIds.Contains(x.SenderId) && recepientIds.Contains(x.RecipientId));
                return(_mapper.Map <IEnumerable <Domain.ChatDomains.Entity.LogEntity>, IEnumerable <SentMessageReportResponseModel> >(logs));
            }
        }