CourseController + new SearchArg for EditionSearchQuery
This commit is contained in:
parent
b9471fe26d
commit
39a4c07a87
51
src/InternshipSystem.Api/Controllers/CourseController.cs
Normal file
51
src/InternshipSystem.Api/Controllers/CourseController.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Controllers
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("management/course")]
|
||||||
|
public class CourseController : ControllerBase
|
||||||
|
{
|
||||||
|
private InternshipDbContext Context { get; }
|
||||||
|
|
||||||
|
public CourseController(InternshipDbContext context)
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult<IReadOnlyCollection<CourseResult>>> GetCourses(CancellationToken cancellationToken) =>
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
[HttpGet("{courseId}")]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult<CourseResult>> GetCourse(long courseId, CancellationToken cancellationToken) =>
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult> UpsertCompany([FromBody] CourseForm courseForm, CancellationToken cancellationToken) =>
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
[HttpDelete("{courseId}")]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult> DeleteCompany(long courseId, CancellationToken cancellationToken) =>
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CourseForm
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CourseResult
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
public async Task<ActionResult<IReadOnlyCollection<EditionManagementResult>>> GetEditions([FromQuery] EditionSearchQuery searchQuery, CancellationToken token) =>
|
public async Task<ActionResult<IReadOnlyCollection<EditionManagementResult>>> GetEditions([FromQuery] EditionSearchQuery searchQuery, CancellationToken token) =>
|
||||||
await Context.Editions
|
await Context.Editions
|
||||||
.Include(e => e.Course)
|
.Include(e => e.Course)
|
||||||
|
.Where(p => !searchQuery.Course.HasValue || p.Course.Id == searchQuery.Course)
|
||||||
.ProjectTo<EditionManagementResult>(Mapper.ConfigurationProvider)
|
.ProjectTo<EditionManagementResult>(Mapper.ConfigurationProvider)
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
.Skip(searchQuery.Page * searchQuery.PerPage)
|
||||||
.Take(searchQuery.PerPage)
|
.Take(searchQuery.PerPage)
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
{
|
{
|
||||||
public class EditionSearchQuery : SearchQuery
|
public class EditionSearchQuery : SearchQuery
|
||||||
{
|
{
|
||||||
|
public long? Course { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,5 +4,6 @@
|
|||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public string NameEng { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,6 +12,7 @@ namespace InternshipSystem.Repository
|
|||||||
public DbSet<StaticPage> StaticPages { get; set; }
|
public DbSet<StaticPage> StaticPages { get; set; }
|
||||||
public DbSet<InternshipType> InternshipTypes { get; set; }
|
public DbSet<InternshipType> InternshipTypes { get; set; }
|
||||||
public DbSet<Student> Students { get; set; }
|
public DbSet<Student> Students { get; set; }
|
||||||
|
public DbSet<Course> Courses { get; set; }
|
||||||
|
|
||||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||||
: base(options)
|
: base(options)
|
||||||
|
Loading…
Reference in New Issue
Block a user