Release v1.0.0 #16
.envnuget.config
.gitea/workflows
.gitignoreApiDto
ApiDto.csproj
Backend.slnDockerfileCommon
Requests
Responses
Endpoint
Backend.httpISaveSettings.cs
README.mdCommon
Attributes
BadRequestResponseAttribute.csCacheMaxAgeAttribute.csLocalhostAttribute.csMaintenanceModeIgnoreAttribute.csNotFoundResponseAttribute.csSwaggerDefaultAttribute.csTokenAuthenticationAttribute.cs
Exceptions
Interfaces
Services
Configuration
Core
Middleware
CacheMaxAgeMiddleware.csCookieAuthorizationMiddleware.csCustomExceptionHandlerMiddleware.csJwtRevocationMiddleware.csMaintenanceModeMiddleware.cs
Startup
Model
SwaggerOptions
Validation
Controllers
BaseController.cs
Endpoint.csprojProgram.csWeatherForecast.csConfiguration
V1
AuthController.csCampusController.csDisciplineController.csFacultyController.csGroupController.csLectureHallController.csProfessorController.csScheduleController.cs
WeatherForecastController.cswwwroot/css/swagger
Security
SqlData
Application
Application.csprojDependencyInjection.cs
Common
Cqrs
Campus/Queries
GetCampusBasicInfoList
CampusBasicInfoDto.csCampusBasicInfoVm.csGetCampusBasicInfoListQuery.csGetCampusBasicInfoListQueryHandler.cs
GetCampusDetails
Discipline/Queries
GetDisciplineDetails
GetDisciplineList
Faculty/Queries
GetFacultyDetails
GetFacultyList
Group/Queries
GetGroupDetails
GetGroupList
LectureHall/Queries
GetLectureHallDetails
GetLectureHallList
Professor/Queries
GetProfessorDetails
GetProfessorDetailsBySearch
GetProfessorList
Schedule/Queries/GetScheduleList
Interfaces/DbContexts
Domain
Domain.csproj
Schedule
Migrations
MysqlMigrations
Migrations
20240601023106_InitialMigration.Designer.cs20240601023106_InitialMigration.csUberDbContextModelSnapshot.cs
MysqlMigrations.csprojPsqlMigrations
Migrations
20240601021702_InitialMigration.Designer.cs20240601021702_InitialMigration.csUberDbContextModelSnapshot.cs
PsqlMigrations.csprojSqliteMigrations
Persistence
Common
BaseDbContext.csConfigurationResolver.csDatabaseProvider.csDbContextFactory.csModelBuilderExtensions.cs
Contexts/Schedule
CampusDbContext.csDisciplineDbContext.csFacultyDbContext.csGroupDbContext.csLectureHallDbContext.csLessonAssociationDbContext.csLessonDbContext.csProfessorDbContext.csSpecificWeekDbContext.csTypeOfOccupationDbContext.cs
DbInitializer.csDependencyInjection.csEntityTypeConfigurations
Mark.cs
Persistence.csprojUberDbContext.csMysql/Schedule
CampusConfiguration.csDisciplineConfiguration.csFacultyConfiguration.csGroupConfiguration.csLectureHallConfiguration.csLessonAssociationConfiguration.csLessonConfiguration.csProfessorConfiguration.csSpecificWeekConfiguration.csTypeOfOccupationConfiguration.cs
Postgresql/Schedule
CampusConfiguration.csDisciplineConfiguration.csFacultyConfiguration.csGroupConfiguration.csLectureHallConfiguration.csLessonAssociationConfiguration.csLessonConfiguration.csProfessorConfiguration.csSpecificWeekConfiguration.csTypeOfOccupationConfiguration.cs
Sqlite/Schedule
@ -2,6 +2,7 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails;
|
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails;
|
||||||
|
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetailsBySearch;
|
||||||
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorList;
|
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorList;
|
||||||
using Mirea.Api.Dto.Responses;
|
using Mirea.Api.Dto.Responses;
|
||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
@ -63,4 +64,35 @@ public class ProfessorController(IMediator mediator) : BaseController
|
|||||||
AltName = result.AltName
|
AltName = result.AltName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves detailed information about professors based on their name.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method searches for professors whose name matches the provided search term.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="name">The name of the professor to search for. Must be at least 4 characters long.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A list of <see cref="ProfessorResponse"/> objects containing the details of the matching professors.
|
||||||
|
/// </returns>
|
||||||
|
[HttpGet("{name:required}")]
|
||||||
|
[BadRequestResponse]
|
||||||
|
[NotFoundResponse]
|
||||||
|
public async Task<ActionResult<List<ProfessorResponse>>> GetDetails(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name) || name.Length < 4)
|
||||||
|
return BadRequest($"The minimum number of characters is 4 (current: {name.Length}).");
|
||||||
|
|
||||||
|
var result = await mediator.Send(new GetProfessorInfoSearchQuery()
|
||||||
|
{
|
||||||
|
Name = name
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(result.Details.Select(x => new ProfessorResponse()
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
Name = x.Name,
|
||||||
|
AltName = x.AltName
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
17
SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetailsBySearch/GetProfessorInfoSearchQuery.cs
Normal file
17
SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetailsBySearch/GetProfessorInfoSearchQuery.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetailsBySearch;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a query to retrieve information about a professor.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This query can be used to fetch details of a professor by either their name.
|
||||||
|
/// </remarks>
|
||||||
|
public class GetProfessorInfoSearchQuery : IRequest<ProfessorInfoListVm>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the professor.
|
||||||
|
/// </summary>
|
||||||
|
public required string Name { get; set; }
|
||||||
|
}
|
33
SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetailsBySearch/GetProfessorInfoSearchQueryHandler.cs
Normal file
33
SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetailsBySearch/GetProfessorInfoSearchQueryHandler.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mirea.Api.DataAccess.Application.Common.Exceptions;
|
||||||
|
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails;
|
||||||
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetailsBySearch;
|
||||||
|
|
||||||
|
public class GetProfessorInfoSearchQueryHandler(IProfessorDbContext dbContext) : IRequestHandler<GetProfessorInfoSearchQuery, ProfessorInfoListVm>
|
||||||
|
{
|
||||||
|
public async Task<ProfessorInfoListVm> Handle(GetProfessorInfoSearchQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var name = request.Name.ToLower();
|
||||||
|
var professor = await dbContext.Professors
|
||||||
|
.Where(p => p.Name.ToLower().Contains(name) ||
|
||||||
|
(p.AltName != null && p.AltName.ToLower().Contains(name)))
|
||||||
|
.ToListAsync(cancellationToken)
|
||||||
|
?? throw new NotFoundException(typeof(Domain.Schedule.Professor), request.Name);
|
||||||
|
|
||||||
|
return new ProfessorInfoListVm()
|
||||||
|
{
|
||||||
|
Details = professor.Select(x => new ProfessorInfoVm()
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
Name = x.Name,
|
||||||
|
AltName = x.AltName
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
15
SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetailsBySearch/ProfessorInfoListVm.cs
Normal file
15
SqlData/Application/Cqrs/Professor/Queries/GetProfessorDetailsBySearch/ProfessorInfoListVm.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetails;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetailsBySearch;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents professors.
|
||||||
|
/// </summary>
|
||||||
|
public class ProfessorInfoListVm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List of <see cref="ProfessorInfoVm"/>
|
||||||
|
/// </summary>
|
||||||
|
public required IList<ProfessorInfoVm> Details { get; set; }
|
||||||
|
}
|
Reference in New Issue
Block a user