This commit is contained in:
Michal Bohdanowicz 2021-01-10 18:31:10 +01:00
commit bab886d28d
6 changed files with 35 additions and 14 deletions

View File

@ -33,7 +33,7 @@
"bearer": [ "bearer": [
{ {
"key": "token", "key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string" "type": "string"
} }
] ]
@ -52,7 +52,7 @@
} }
], ],
"url": { "url": {
"raw": "http://localhost:8080/management/internship?OrderByField=InternshipState&SortOrder=Desc", "raw": "http://localhost:8080/management/internship?OrderByField=InternshipState&SortOrder=Asc",
"protocol": "http", "protocol": "http",
"host": [ "host": [
"localhost" "localhost"
@ -69,7 +69,7 @@
}, },
{ {
"key": "SortOrder", "key": "SortOrder",
"value": "Desc" "value": "Asc"
} }
] ]
} }
@ -84,7 +84,7 @@
"bearer": [ "bearer": [
{ {
"key": "token", "key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string" "type": "string"
} }
] ]
@ -126,7 +126,7 @@
"bearer": [ "bearer": [
{ {
"key": "token", "key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string" "type": "string"
} }
] ]
@ -144,6 +144,10 @@
"value": "application/json" "value": "application/json"
} }
], ],
"body": {
"mode": "raw",
"raw": "\"\""
},
"url": { "url": {
"raw": "http://localhost:8080/management/internship/accept/1", "raw": "http://localhost:8080/management/internship/accept/1",
"protocol": "http", "protocol": "http",
@ -169,7 +173,7 @@
"bearer": [ "bearer": [
{ {
"key": "token", "key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string" "type": "string"
} }
] ]
@ -187,6 +191,10 @@
"value": "application/json" "value": "application/json"
} }
], ],
"body": {
"mode": "raw",
"raw": "\"Co żeś odrąbał andzeju\""
},
"url": { "url": {
"raw": "http://localhost:8080/management/internship/reject/1", "raw": "http://localhost:8080/management/internship/reject/1",
"protocol": "http", "protocol": "http",
@ -855,6 +863,5 @@
}, },
"response": [] "response": []
} }
], ]
"protocolProfileBehavior": {}
} }

View File

@ -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);

View File

@ -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()
{ {

View File

@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations namespace InternshipSystem.Repository.Migrations
{ {
[DbContext(typeof(InternshipDbContext))] [DbContext(typeof(InternshipDbContext))]
[Migration("20210110173006_Init")] [Migration("20210110173104_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");

View File

@ -198,7 +198,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 =>
{ {

View File

@ -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");