mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-03 19:17:05 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			962 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			962 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Threading.Tasks;
 | 
						|
using API.DTOs.Email;
 | 
						|
using API.Entities;
 | 
						|
using API.Helpers;
 | 
						|
using AutoMapper;
 | 
						|
using AutoMapper.QueryableExtensions;
 | 
						|
using Microsoft.EntityFrameworkCore;
 | 
						|
 | 
						|
namespace API.Data.Repositories;
 | 
						|
 | 
						|
public interface IEmailHistoryRepository
 | 
						|
{
 | 
						|
    Task<IList<EmailHistoryDto>> GetEmailDtos(UserParams userParams);
 | 
						|
}
 | 
						|
 | 
						|
public class EmailHistoryRepository : IEmailHistoryRepository
 | 
						|
{
 | 
						|
    private readonly DataContext _context;
 | 
						|
    private readonly IMapper _mapper;
 | 
						|
 | 
						|
    public EmailHistoryRepository(DataContext context, IMapper mapper)
 | 
						|
    {
 | 
						|
        _context = context;
 | 
						|
        _mapper = mapper;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public async Task<IList<EmailHistoryDto>> GetEmailDtos(UserParams userParams)
 | 
						|
    {
 | 
						|
        return await _context.EmailHistory
 | 
						|
            .OrderByDescending(h => h.SendDate)
 | 
						|
            .ProjectTo<EmailHistoryDto>(_mapper.ConfigurationProvider)
 | 
						|
            .ToListAsync();
 | 
						|
    }
 | 
						|
}
 |