feat: add queries for professor
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m44s
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m44s
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
using MediatR;
|
||||
|
||||
namespace Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails;
|
||||
|
||||
public class GetProfessorInfoQuery : IRequest<ProfessorInfoVm>
|
||||
{
|
||||
public required int Id { get; set; }
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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)
|
||||
{
|
||||
var discipline = await dbContext.Professors.FirstOrDefaultAsync(p => p.Id == request.Id, cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.Group), request.Id);
|
||||
|
||||
return new ProfessorInfoVm()
|
||||
{
|
||||
Id = discipline.Id,
|
||||
Name = discipline.Name,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails;
|
||||
|
||||
/// <summary>
|
||||
/// Represents professors.
|
||||
/// </summary>
|
||||
public class ProfessorInfoVm
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique identifier for the professor.
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the professor.
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The alt name of the professor. Usually is full name.
|
||||
/// </summary>
|
||||
public string? AltName { get; set; }
|
||||
}
|
Reference in New Issue
Block a user