Polianin Nikita
bc99007d94
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m36s
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using System.Globalization;
|
|
using System.Linq;
|
|
using MediatR;
|
|
using Mirea.Api.DataAccess.Application.Cqrs.Campus.Queries.GetCampusBasicInfoList;
|
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Mirea.Api.DataAccess.Application.Common.Exceptions;
|
|
|
|
namespace Mirea.Api.DataAccess.Application.Cqrs.Campus.Queries.GetCampusDetails;
|
|
|
|
public class GetCampusDetailsQueryHandler(ICampusDbContext dbContext) : IRequestHandler<GetCampusDetailsQuery, CampusDetailsVm>
|
|
{
|
|
public async Task<CampusDetailsVm> Handle(GetCampusDetailsQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var campus = await dbContext.Campuses.FirstOrDefaultAsync(c => c.Id == request.Id, cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.Campus), request.Id);
|
|
|
|
return new CampusDetailsVm()
|
|
{
|
|
Id = campus.Id,
|
|
CodeName = campus.CodeName,
|
|
FullName = campus.FullName,
|
|
Address = campus.Address
|
|
};
|
|
}
|
|
} |