InternshipType and Documents added to list. ChangeStateComment field for accept and reject
This commit is contained in:
parent
6d8d7a7c0a
commit
0ef4eeb0ac
@ -35,7 +35,9 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
Context.Internships
|
Context.Internships
|
||||||
.Include(i => i.Edition)
|
.Include(i => i.Edition)
|
||||||
.Include(i => i.InternshipRegistration)
|
.Include(i => i.InternshipRegistration)
|
||||||
|
.Include(i => i.InternshipRegistration.Type)
|
||||||
.Include(i => i.Student)
|
.Include(i => i.Student)
|
||||||
|
.Include(i => i.Documentation)
|
||||||
.Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id.Equals(searchQuery.EditionId))
|
.Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id.Equals(searchQuery.EditionId))
|
||||||
.Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State.Equals(searchQuery.InternshipState))
|
.Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State.Equals(searchQuery.InternshipState))
|
||||||
.Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber.Equals(searchQuery.StudentAlbumNumber))
|
.Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber.Equals(searchQuery.StudentAlbumNumber))
|
||||||
@ -76,7 +78,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
.Include(i => i.InternshipRegistration.BranchAddress)
|
.Include(i => i.InternshipRegistration.BranchAddress)
|
||||||
.Include(i => i.InternshipRegistration.Type)
|
.Include(i => i.InternshipRegistration.Type)
|
||||||
.Include(i => i.InternshipRegistration.Subjects)
|
.Include(i => i.InternshipRegistration.Subjects)
|
||||||
.ThenInclude(subject => subject.Subject)
|
.ThenInclude(subject => subject.Subject)
|
||||||
.Include(i => i.InternshipRegistration.Mentor)
|
.Include(i => i.InternshipRegistration.Mentor)
|
||||||
.Include(i => i.Report)
|
.Include(i => i.Report)
|
||||||
.Include(i => i.Documentation)
|
.Include(i => i.Documentation)
|
||||||
@ -97,7 +99,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
public async Task<ActionResult> AcceptInternship(long internshipId, CancellationToken token)
|
public async Task<ActionResult> AcceptInternship(long internshipId, [FromBody] string comment, CancellationToken token)
|
||||||
{
|
{
|
||||||
var internship = await Context.Internships
|
var internship = await Context.Internships
|
||||||
.Include(i => i.InternshipRegistration)
|
.Include(i => i.InternshipRegistration)
|
||||||
@ -109,7 +111,8 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
internship.InternshipRegistration.State = DocumentState.Accepted;
|
internship.InternshipRegistration.State = DocumentState.Accepted;
|
||||||
|
internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
await Context.SaveChangesAsync(token);
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
@ -120,7 +123,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
public async Task<ActionResult> RejectInternship(long internshipId, CancellationToken token)
|
public async Task<ActionResult> RejectInternship(long internshipId, [FromBody] string comment, CancellationToken token)
|
||||||
{
|
{
|
||||||
var internship = await Context.Internships
|
var internship = await Context.Internships
|
||||||
.Include(i => i.InternshipRegistration)
|
.Include(i => i.InternshipRegistration)
|
||||||
@ -132,6 +135,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
internship.InternshipRegistration.State = DocumentState.Rejected;
|
internship.InternshipRegistration.State = DocumentState.Rejected;
|
||||||
|
internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
await Context.SaveChangesAsync(token);
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ namespace InternshipSystem.Core.Entity.Internship
|
|||||||
public InternshipType Type { get; set; }
|
public InternshipType Type { get; set; }
|
||||||
public int DeclaredHours { get; set; }
|
public int DeclaredHours { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
|
public string ChangeStateComment { get; set; }
|
||||||
|
|
||||||
public static InternshipRegistration Create()
|
public static InternshipRegistration Create()
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace InternshipSystem.Repository.Migrations
|
namespace InternshipSystem.Repository.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(InternshipDbContext))]
|
[DbContext(typeof(InternshipDbContext))]
|
||||||
[Migration("20210109193303_init")]
|
[Migration("20210110082601_init")]
|
||||||
partial class init
|
partial class init
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -249,6 +249,10 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.HasColumnName("branch_address_id")
|
.HasColumnName("branch_address_id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("ChangeStateComment")
|
||||||
|
.HasColumnName("change_state_comment")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<long?>("CompanyId")
|
b.Property<long?>("CompanyId")
|
||||||
.HasColumnName("company_id")
|
.HasColumnName("company_id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
@ -180,7 +180,8 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
phone_number = table.Column<string>(nullable: true),
|
phone_number = table.Column<string>(nullable: true),
|
||||||
type_id = table.Column<long>(nullable: true),
|
type_id = table.Column<long>(nullable: true),
|
||||||
declared_hours = table.Column<int>(nullable: false),
|
declared_hours = table.Column<int>(nullable: false),
|
||||||
state = table.Column<int>(nullable: false)
|
state = table.Column<int>(nullable: false),
|
||||||
|
change_state_comment = table.Column<string>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
@ -247,6 +247,10 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.HasColumnName("branch_address_id")
|
.HasColumnName("branch_address_id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("ChangeStateComment")
|
||||||
|
.HasColumnName("change_state_comment")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<long?>("CompanyId")
|
b.Property<long?>("CompanyId")
|
||||||
.HasColumnName("company_id")
|
.HasColumnName("company_id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
Loading…
Reference in New Issue
Block a user