using MediatR; using Microsoft.EntityFrameworkCore; using Mirea.Api.DataAccess.Application.Common.Exceptions; using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule; using System.Threading; using System.Threading.Tasks; namespace Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails; public class GetProfessorInfoQueryHandler(IProfessorDbContext dbContext) : IRequestHandler { public async Task Handle(GetProfessorInfoQuery request, CancellationToken cancellationToken) { var discipline = await dbContext.Professors.FirstOrDefaultAsync(p => p.Id == request.Id, cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.Professor), request.Id); return new ProfessorInfoVm() { Id = discipline.Id, Name = discipline.Name, }; } }