using Microsoft.EntityFrameworkCore; using vendorApproverBackend.Data; using System.Globalization; using vendorApproverBackend.Requests; using vendorApproverBackend.Entities; using vendorApproverBackend.Enums; using vendorApproverBackend.Responses; using System.Threading.Tasks; public class PqClarificationService { private readonly DataContext _context; public PqClarificationService(DataContext context) { _context = context; } public async Task AddPqClarificationAsync(CreatePqClarificationDto dto) { var clarification = new PqRequestClarification { PrequalificationRequestId = dto.PrequalificationRequestId, StepObservations = dto.StepObservations, Sender = dto.Sender, Receiver = dto.Receiver, DeadlineReply = dto.DeadlineReply, Comment = dto.Comment }; _context.PqRequestClarifications.Add(clarification); await _context.SaveChangesAsync(); return clarification; } public async Task GetByIdAsync(long id) => await _context.PqRequestClarifications.FindAsync(id); public async Task> GetByRequestIdAsync(long requestId, PqClarificationRoleEnum? receiver) { var query = _context.PqRequestClarifications .Where(c => c.PrequalificationRequestId == requestId); // If receiver is provided (not null), filter by it if (receiver.HasValue) query = query.Where(c => c.Receiver == receiver.Value); return await query.ToListAsync(); } }