feat: add an annotation to the data
This commit is contained in:
parent
e4b942d062
commit
544ad6e791
@ -6,6 +6,7 @@ using Mirea.Api.DataAccess.Application.Cqrs.Discipline.Queries.GetDisciplineList
|
|||||||
using Mirea.Api.Dto.Responses;
|
using Mirea.Api.Dto.Responses;
|
||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public class DisciplineController(IMediator mediator) : BaseController
|
|||||||
/// <returns>Paginated list of disciplines.</returns>
|
/// <returns>Paginated list of disciplines.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
public async Task<ActionResult<List<DisciplineResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
public async Task<ActionResult<List<DisciplineResponse>>> Get([FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? pageSize)
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetDisciplineListQuery()
|
var result = await mediator.Send(new GetDisciplineListQuery()
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ using Mirea.Api.DataAccess.Application.Cqrs.Faculty.Queries.GetFacultyList;
|
|||||||
using Mirea.Api.Dto.Responses;
|
using Mirea.Api.Dto.Responses;
|
||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public class FacultyController(IMediator mediator) : BaseController
|
|||||||
/// <returns>Paginated list of faculties.</returns>
|
/// <returns>Paginated list of faculties.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
public async Task<ActionResult<List<FacultyResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
public async Task<ActionResult<List<FacultyResponse>>> Get([FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? pageSize)
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetFacultyListQuery()
|
var result = await mediator.Send(new GetFacultyListQuery()
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ using Mirea.Api.Dto.Responses;
|
|||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ public class GroupController(IMediator mediator) : BaseController
|
|||||||
/// <returns>A list of groups.</returns>
|
/// <returns>A list of groups.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
public async Task<ActionResult<List<GroupResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
public async Task<ActionResult<List<GroupResponse>>> Get([FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? pageSize)
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetGroupListQuery()
|
var result = await mediator.Send(new GetGroupListQuery()
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,9 @@ using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetail
|
|||||||
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;
|
||||||
|
using Mirea.Api.Endpoint.Common.Exceptions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ public class ProfessorController(IMediator mediator) : BaseController
|
|||||||
/// <returns>A list of professors.</returns>
|
/// <returns>A list of professors.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
public async Task<ActionResult<List<ProfessorResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
public async Task<ActionResult<List<ProfessorResponse>>> Get([FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? pageSize)
|
||||||
{
|
{
|
||||||
var result = await mediator.Send(new GetProfessorListQuery()
|
var result = await mediator.Send(new GetProfessorListQuery()
|
||||||
{
|
{
|
||||||
@ -78,7 +80,7 @@ public class ProfessorController(IMediator mediator) : BaseController
|
|||||||
[HttpGet("{name:required}")]
|
[HttpGet("{name:required}")]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
[NotFoundResponse]
|
[NotFoundResponse]
|
||||||
public async Task<ActionResult<List<ProfessorResponse>>> GetDetails(string name)
|
public async Task<ActionResult<List<ProfessorResponse>>> GetDetails([MinLength(4)] string name)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(name) || name.Length < 4)
|
if (string.IsNullOrEmpty(name) || name.Length < 4)
|
||||||
throw new ControllerArgumentException($"The minimum number of characters is 4 (current: {name.Length}).");
|
throw new ControllerArgumentException($"The minimum number of characters is 4 (current: {name.Length}).");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user