Spaces:
Running
Running
Claude Opus 5.5
feat: remove AI assistant, Free/Plus plans, user templates API, security fixes
6d07d79 Download FlowAPI.Infrastructure/Repositories/CustomTemplateRepository.cs from DanilDrotik/FlowAPI: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/spaces/DanilDrotik/FlowAPI/resolve/main/FlowAPI.Infrastructure/Repositories/CustomTemplateRepository.cs
- Command line
-
hf download hf://spaces/DanilDrotik/FlowAPI/FlowAPI.Infrastructure/Repositories/CustomTemplateRepository.cs
-
curl -L -o CustomTemplateRepository.cs https://huggingface.co/spaces/DanilDrotik/FlowAPI/resolve/main/FlowAPI.Infrastructure/Repositories/CustomTemplateRepository.cs
1.95 kB
| 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<CustomTemplate?> GetByIdAsync(Guid id) | |
| { | |
| return await _context.CustomTemplates.FirstOrDefaultAsync(t => t.Id == id); | |
| } | |
| public async Task<IEnumerable<CustomTemplate>> GetByUserIdAsync(Guid userId) | |
| { | |
| return await _context.CustomTemplates | |
| .Where(t => t.UserId == userId) | |
| .OrderByDescending(t => t.CreatedAt) | |
| .ToListAsync(); | |
| } | |
| public async Task<CustomTemplate> CreateAsync(CustomTemplate template) | |
| { | |
| _context.CustomTemplates.Add(template); | |
| await _context.SaveChangesAsync(); | |
| return template; | |
| } | |
| public async Task<CustomTemplate> UpdateAsync(CustomTemplate template) | |
| { | |
| _context.CustomTemplates.Update(template); | |
| await _context.SaveChangesAsync(); | |
| return template; | |
| } | |
| public async Task<bool> DeleteAsync(Guid id) | |
| { | |
| var template = await _context.CustomTemplates.FindAsync(id); | |
| if (template is null) return false; | |
| _context.CustomTemplates.Remove(template); | |
| await _context.SaveChangesAsync(); | |
| return true; | |
| } | |
| public async Task<int> CountByUserIdAsync(Guid userId) | |
| { | |
| return await _context.CustomTemplates.CountAsync(t => t.UserId == userId); | |
| } | |
| } | |
| } | |