2024-02-16 18:06:22 +03:00
|
|
|
|
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<GetProfessorInfoQuery, ProfessorInfoVm>
|
|
|
|
|
{
|
|
|
|
|
public async Task<ProfessorInfoVm> Handle(GetProfessorInfoQuery request, CancellationToken cancellationToken)
|
|
|
|
|
{
|
2024-02-16 22:35:15 +03:00
|
|
|
|
var discipline = await dbContext.Professors.FirstOrDefaultAsync(p => p.Id == request.Id, cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.Professor), request.Id);
|
2024-02-16 18:06:22 +03:00
|
|
|
|
|
|
|
|
|
return new ProfessorInfoVm()
|
|
|
|
|
{
|
|
|
|
|
Id = discipline.Id,
|
|
|
|
|
Name = discipline.Name,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|