refactor: move database-related projects to separate folder

This commit is contained in:
2024-05-29 07:49:42 +03:00
parent 081c814036
commit bf3a9d4b36
74 changed files with 5 additions and 43 deletions

View File

@ -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; }
}

View File

@ -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.Professor), request.Id);
return new ProfessorInfoVm()
{
Id = discipline.Id,
Name = discipline.Name,
};
}
}

View File

@ -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; }
}