using FlowAPI.Application.Interfaces; using FlowAPI.Domain.Entities; using FlowAPI.Infrastructure.Data; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace FlowAPI.Infrastructure.Repositories { public class CustomTemplateRepository : ICustomTemplateRepository { private readonly AppDbContext _context; public CustomTemplateRepository(AppDbContext context) { _context = context; } public async Task GetByIdAsync(Guid id) { return await _context.CustomTemplates.FirstOrDefaultAsync(t => t.Id == id); } public async Task> GetByUserIdAsync(Guid userId) { return await _context.CustomTemplates .Where(t => t.UserId == userId) .OrderByDescending(t => t.CreatedAt) .ToListAsync(); } public async Task CreateAsync(CustomTemplate template) { _context.CustomTemplates.Add(template); await _context.SaveChangesAsync(); return template; } } }