Internship management
This commit is contained in:
parent
2779667ce8
commit
6d8d7a7c0a
@ -25,6 +25,185 @@
|
|||||||
},
|
},
|
||||||
"response": []
|
"response": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "GetInternshipManagementList",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "bearer",
|
||||||
|
"bearer": [
|
||||||
|
{
|
||||||
|
"key": "token",
|
||||||
|
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"type": "text",
|
||||||
|
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"type": "text",
|
||||||
|
"value": "application/json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/management/internship?OrderByField=InternshipState&SortOrder=Desc",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"management",
|
||||||
|
"internship"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "OrderByField",
|
||||||
|
"value": "InternshipState"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "SortOrder",
|
||||||
|
"value": "Desc"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GetInternshipManagement",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "bearer",
|
||||||
|
"bearer": [
|
||||||
|
{
|
||||||
|
"key": "token",
|
||||||
|
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"type": "text",
|
||||||
|
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"type": "text",
|
||||||
|
"value": "application/json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/management/internship/1",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"management",
|
||||||
|
"internship",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GetInternshipManagementAccept",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "bearer",
|
||||||
|
"bearer": [
|
||||||
|
{
|
||||||
|
"key": "token",
|
||||||
|
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"method": "PUT",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"type": "text",
|
||||||
|
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"type": "text",
|
||||||
|
"value": "application/json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/management/internship/accept/1",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"management",
|
||||||
|
"internship",
|
||||||
|
"accept",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GetInternshipManagementReject",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "bearer",
|
||||||
|
"bearer": [
|
||||||
|
{
|
||||||
|
"key": "token",
|
||||||
|
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"method": "PUT",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"type": "text",
|
||||||
|
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"type": "text",
|
||||||
|
"value": "application/json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/management/internship/reject/1",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"management",
|
||||||
|
"internship",
|
||||||
|
"reject",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "loginEdition",
|
"name": "loginEdition",
|
||||||
"request": {
|
"request": {
|
||||||
|
@ -0,0 +1,141 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using InternshipSystem.Api.Queries.SearchQuery;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
|
using InternshipSystem.Core;
|
||||||
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Controllers
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("management/internship")]
|
||||||
|
public class InternshipManagementController : ControllerBase
|
||||||
|
{
|
||||||
|
private InternshipDbContext Context { get; }
|
||||||
|
|
||||||
|
public InternshipManagementController(InternshipDbContext context)
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult<IReadOnlyCollection<Internship>>> GetInternships([FromQuery] InternshipSearchQuery searchQuery, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query =
|
||||||
|
Context.Internships
|
||||||
|
.Include(i => i.Edition)
|
||||||
|
.Include(i => i.InternshipRegistration)
|
||||||
|
.Include(i => i.Student)
|
||||||
|
.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.StudentAlbumNumber.HasValue || i.Student.AlbumNumber.Equals(searchQuery.StudentAlbumNumber))
|
||||||
|
.Where(i => string.IsNullOrEmpty(searchQuery.StudentFirstName) || i.Student.FirstName.ToLower().Contains(searchQuery.StudentFirstName.ToLower()))
|
||||||
|
.Where(i => string.IsNullOrEmpty(searchQuery.StudentLastName) || i.Student.LastName.ToLower().Contains(searchQuery.StudentLastName.ToLower()))
|
||||||
|
.Skip(searchQuery.Page * searchQuery.PerPage)
|
||||||
|
.Take(searchQuery.PerPage);
|
||||||
|
|
||||||
|
if (searchQuery.OrderByField.ToLower().Equals("date"))
|
||||||
|
{
|
||||||
|
query = searchQuery.SortOrder.Equals(SortOrder.Desc) ?
|
||||||
|
query.OrderByDescending(i => i.InternshipRegistration.SubmissionDate) :
|
||||||
|
query.OrderBy(i => i.InternshipRegistration.SubmissionDate);
|
||||||
|
}
|
||||||
|
else if (searchQuery.OrderByField.ToLower().Equals("internshipstate"))
|
||||||
|
{
|
||||||
|
query = searchQuery.SortOrder.Equals(SortOrder.Desc) ?
|
||||||
|
query.OrderByDescending(i => i.InternshipRegistration.State) :
|
||||||
|
query.OrderBy(i => i.InternshipRegistration.State);
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await query.ToListAsync(token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{internshipId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult<Internship>> GetInternship(long internshipId, CancellationToken token)
|
||||||
|
{
|
||||||
|
var internship = await Context.Internships
|
||||||
|
.Include(i => i.Student)
|
||||||
|
.Include(i => i.InternshipRegistration)
|
||||||
|
.Include(i => i.InternshipRegistration.Company)
|
||||||
|
.Include(i => i.InternshipRegistration.BranchAddress)
|
||||||
|
.Include(i => i.InternshipRegistration.Type)
|
||||||
|
.Include(i => i.InternshipRegistration.Subjects)
|
||||||
|
.ThenInclude(subject => subject.Subject)
|
||||||
|
.Include(i => i.InternshipRegistration.Mentor)
|
||||||
|
.Include(i => i.Report)
|
||||||
|
.Include(i => i.Documentation)
|
||||||
|
.Include(i => i.Edition)
|
||||||
|
.Where(i => i.Id.Equals(internshipId))
|
||||||
|
.FirstOrDefaultAsync(token);
|
||||||
|
|
||||||
|
if (internship == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(internship);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("accept/{internshipId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult> AcceptInternship(long internshipId, CancellationToken token)
|
||||||
|
{
|
||||||
|
var internship = await Context.Internships
|
||||||
|
.Include(i => i.InternshipRegistration)
|
||||||
|
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
|
||||||
|
|
||||||
|
if (internship == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
internship.InternshipRegistration.State = DocumentState.Accepted;
|
||||||
|
|
||||||
|
await Context.SaveChangesAsync(token);
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("reject/{internshipId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[Authorize(Policy = Policies.IsOverseer)]
|
||||||
|
public async Task<ActionResult> RejectInternship(long internshipId, CancellationToken token)
|
||||||
|
{
|
||||||
|
var internship = await Context.Internships
|
||||||
|
.Include(i => i.InternshipRegistration)
|
||||||
|
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
|
||||||
|
|
||||||
|
if (internship == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
internship.InternshipRegistration.State = DocumentState.Rejected;
|
||||||
|
|
||||||
|
await Context.SaveChangesAsync(token);
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using InternshipSystem.Core;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Queries.SearchQuery
|
||||||
|
{
|
||||||
|
public class InternshipSearchQuery : SearchQuery
|
||||||
|
{
|
||||||
|
public Guid? EditionId { get; set; } = null;
|
||||||
|
public DocumentState? InternshipState { get; set; } = null;
|
||||||
|
public int? StudentAlbumNumber { get; set; } = null;
|
||||||
|
public string StudentFirstName { get; set; } = "";
|
||||||
|
public string StudentLastName { get; set; } = "";
|
||||||
|
/// <summary>
|
||||||
|
/// SortValue: Date, InternshipState
|
||||||
|
/// </summary>
|
||||||
|
public string OrderByField { get; set; } = "";
|
||||||
|
public SortOrder SortOrder { get; set; } = SortOrder.None;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace InternshipSystem.Api.Queries.SearchQuery
|
||||||
|
{
|
||||||
|
public enum SortOrder
|
||||||
|
{
|
||||||
|
Asc,
|
||||||
|
Desc,
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,6 @@ namespace InternshipSystem.Core.Entity.Internship
|
|||||||
public InternshipRegistration InternshipRegistration { get; set; }
|
public InternshipRegistration InternshipRegistration { get; set; }
|
||||||
public Report Report { get; set; }
|
public Report Report { get; set; }
|
||||||
public List<Document> Documentation { get; set; }
|
public List<Document> Documentation { get; set; }
|
||||||
|
|
||||||
public Edition Edition { get; set; }
|
public Edition Edition { get; set; }
|
||||||
|
|
||||||
public float? Grade { get; set; }
|
public float? Grade { get; set; }
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Entity.Internship
|
namespace InternshipSystem.Core.Entity.Internship
|
||||||
@ -13,12 +11,12 @@ namespace InternshipSystem.Core.Entity.Internship
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public Company Company { get; set; }
|
public Company Company { get; set; }
|
||||||
public BranchOffice BranchAddress { get; set; }
|
public BranchOffice BranchAddress { get; set; }
|
||||||
|
public DateTime SubmissionDate { get; set; }
|
||||||
public DateTime Start { get; set; }
|
public DateTime Start { get; set; }
|
||||||
public DateTime End { get; set; }
|
public DateTime End { get; set; }
|
||||||
public Mentor Mentor { get; set; }
|
public Mentor Mentor { get; set; }
|
||||||
public List<ProgramSubject> Subjects { get; set; }
|
public List<ProgramSubject> Subjects { get; set; }
|
||||||
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; }
|
||||||
|
|
||||||
@ -36,6 +34,8 @@ namespace InternshipSystem.Core.Entity.Internship
|
|||||||
|
|
||||||
State = result.IsValid ? DocumentState.Submitted : DocumentState.Draft;
|
State = result.IsValid ? DocumentState.Submitted : DocumentState.Draft;
|
||||||
|
|
||||||
|
SubmissionDate = DocumentState.Submitted.Equals(State) ? DateTime.UtcNow.AddHours(1) : SubmissionDate;
|
||||||
|
|
||||||
return (State, result.ToErrorDescription());
|
return (State, result.ToErrorDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +305,7 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
Company = Context.Companies.First(c => c.Name.Equals("Intel")),
|
Company = Context.Companies.First(c => c.Name.Equals("Intel")),
|
||||||
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")),
|
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")),
|
||||||
|
SubmissionDate = new DateTime(2000, 6, 2),
|
||||||
Start = new DateTime(2000, 7, 1),
|
Start = new DateTime(2000, 7, 1),
|
||||||
End = new DateTime(2000, 8, 30),
|
End = new DateTime(2000, 8, 30),
|
||||||
State = DocumentState.Submitted,
|
State = DocumentState.Submitted,
|
||||||
@ -351,6 +352,7 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")),
|
Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")),
|
||||||
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")),
|
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")),
|
||||||
|
SubmissionDate = new DateTime(2000, 6, 1),
|
||||||
Start = new DateTime(2000, 7, 1),
|
Start = new DateTime(2000, 7, 1),
|
||||||
End = new DateTime(2000, 8, 30),
|
End = new DateTime(2000, 8, 30),
|
||||||
State = DocumentState.Submitted,
|
State = DocumentState.Submitted,
|
||||||
|
@ -14,6 +14,7 @@ namespace InternshipSystem.Repository
|
|||||||
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 DbSet<Course> Courses { get; set; }
|
||||||
|
public DbSet<Internship> Internships { get; set; }
|
||||||
|
|
||||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||||
: base(options)
|
: base(options)
|
||||||
|
@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace InternshipSystem.Repository.Migrations
|
namespace InternshipSystem.Repository.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(InternshipDbContext))]
|
[DbContext(typeof(InternshipDbContext))]
|
||||||
[Migration("20201128203805_init")]
|
[Migration("20210109193303_init")]
|
||||||
partial class init
|
partial class init
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -220,21 +220,21 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("Id")
|
||||||
.HasName("pk_internship");
|
.HasName("pk_internships");
|
||||||
|
|
||||||
b.HasIndex("EditionId")
|
b.HasIndex("EditionId")
|
||||||
.HasName("ix_internship_edition_id");
|
.HasName("ix_internships_edition_id");
|
||||||
|
|
||||||
b.HasIndex("InternshipRegistrationId")
|
b.HasIndex("InternshipRegistrationId")
|
||||||
.HasName("ix_internship_internship_registration_id");
|
.HasName("ix_internships_internship_registration_id");
|
||||||
|
|
||||||
b.HasIndex("ReportId")
|
b.HasIndex("ReportId")
|
||||||
.HasName("ix_internship_report_id");
|
.HasName("ix_internships_report_id");
|
||||||
|
|
||||||
b.HasIndex("StudentId")
|
b.HasIndex("StudentId")
|
||||||
.HasName("ix_internship_student_id");
|
.HasName("ix_internships_student_id");
|
||||||
|
|
||||||
b.ToTable("internship");
|
b.ToTable("internships");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
||||||
@ -269,6 +269,10 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.HasColumnName("state")
|
.HasColumnName("state")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("SubmissionDate")
|
||||||
|
.HasColumnName("submission_date")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<long?>("TypeId")
|
b.Property<long?>("TypeId")
|
||||||
.HasColumnName("type_id")
|
.HasColumnName("type_id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
@ -546,7 +550,7 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
|
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
|
||||||
.WithMany("Documentation")
|
.WithMany("Documentation")
|
||||||
.HasForeignKey("InternshipId")
|
.HasForeignKey("InternshipId")
|
||||||
.HasConstraintName("fk_document_internship_internship_id");
|
.HasConstraintName("fk_document_internships_internship_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
||||||
@ -572,22 +576,22 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
||||||
.WithMany("Internships")
|
.WithMany("Internships")
|
||||||
.HasForeignKey("EditionId")
|
.HasForeignKey("EditionId")
|
||||||
.HasConstraintName("fk_internship_editions_edition_id");
|
.HasConstraintName("fk_internships_editions_edition_id");
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
.HasForeignKey("InternshipRegistrationId")
|
||||||
.HasConstraintName("fk_internship_internship_registration_internship_registration_");
|
.HasConstraintName("fk_internships_internship_registration_internship_registration");
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Report", "Report")
|
b.HasOne("InternshipSystem.Core.Report", "Report")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("ReportId")
|
.HasForeignKey("ReportId")
|
||||||
.HasConstraintName("fk_internship_report_report_id");
|
.HasConstraintName("fk_internships_report_report_id");
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Student", "Student")
|
b.HasOne("InternshipSystem.Core.Student", "Student")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("StudentId")
|
.HasForeignKey("StudentId")
|
||||||
.HasConstraintName("fk_internship_students_student_id");
|
.HasConstraintName("fk_internships_students_student_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
@ -171,6 +171,7 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
company_id = table.Column<long>(nullable: true),
|
company_id = table.Column<long>(nullable: true),
|
||||||
branch_address_id = table.Column<long>(nullable: true),
|
branch_address_id = table.Column<long>(nullable: true),
|
||||||
|
submission_date = table.Column<DateTime>(nullable: false),
|
||||||
start = table.Column<DateTime>(nullable: false),
|
start = table.Column<DateTime>(nullable: false),
|
||||||
end = table.Column<DateTime>(nullable: false),
|
end = table.Column<DateTime>(nullable: false),
|
||||||
first_name = table.Column<string>(nullable: true),
|
first_name = table.Column<string>(nullable: true),
|
||||||
@ -253,7 +254,7 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "internship",
|
name: "internships",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
id = table.Column<long>(nullable: false)
|
id = table.Column<long>(nullable: false)
|
||||||
@ -266,27 +267,27 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("pk_internship", x => x.id);
|
table.PrimaryKey("pk_internships", x => x.id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "fk_internship_editions_edition_id",
|
name: "fk_internships_editions_edition_id",
|
||||||
column: x => x.edition_id,
|
column: x => x.edition_id,
|
||||||
principalTable: "editions",
|
principalTable: "editions",
|
||||||
principalColumn: "id",
|
principalColumn: "id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "fk_internship_internship_registration_internship_registration_",
|
name: "fk_internships_internship_registration_internship_registration",
|
||||||
column: x => x.internship_registration_id,
|
column: x => x.internship_registration_id,
|
||||||
principalTable: "internship_registration",
|
principalTable: "internship_registration",
|
||||||
principalColumn: "id",
|
principalColumn: "id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "fk_internship_report_report_id",
|
name: "fk_internships_report_report_id",
|
||||||
column: x => x.report_id,
|
column: x => x.report_id,
|
||||||
principalTable: "report",
|
principalTable: "report",
|
||||||
principalColumn: "id",
|
principalColumn: "id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "fk_internship_students_student_id",
|
name: "fk_internships_students_student_id",
|
||||||
column: x => x.student_id,
|
column: x => x.student_id,
|
||||||
principalTable: "students",
|
principalTable: "students",
|
||||||
principalColumn: "id",
|
principalColumn: "id",
|
||||||
@ -333,9 +334,9 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
{
|
{
|
||||||
table.PrimaryKey("pk_document", x => x.id);
|
table.PrimaryKey("pk_document", x => x.id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "fk_document_internship_internship_id",
|
name: "fk_document_internships_internship_id",
|
||||||
column: x => x.internship_id,
|
column: x => x.internship_id,
|
||||||
principalTable: "internship",
|
principalTable: "internships",
|
||||||
principalColumn: "id",
|
principalColumn: "id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
@ -386,26 +387,6 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
table: "editions",
|
table: "editions",
|
||||||
column: "course_id");
|
column: "course_id");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_edition_id",
|
|
||||||
table: "internship",
|
|
||||||
column: "edition_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_internship_registration_id",
|
|
||||||
table: "internship",
|
|
||||||
column: "internship_registration_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_report_id",
|
|
||||||
table: "internship",
|
|
||||||
column: "report_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_student_id",
|
|
||||||
table: "internship",
|
|
||||||
column: "student_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "ix_internship_registration_branch_address_id",
|
name: "ix_internship_registration_branch_address_id",
|
||||||
table: "internship_registration",
|
table: "internship_registration",
|
||||||
@ -421,6 +402,26 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
table: "internship_registration",
|
table: "internship_registration",
|
||||||
column: "type_id");
|
column: "type_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internships_edition_id",
|
||||||
|
table: "internships",
|
||||||
|
column: "edition_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internships_internship_registration_id",
|
||||||
|
table: "internships",
|
||||||
|
column: "internship_registration_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internships_report_id",
|
||||||
|
table: "internships",
|
||||||
|
column: "report_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internships_student_id",
|
||||||
|
table: "internships",
|
||||||
|
column: "student_id");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "ix_program_subject_internship_subject_id",
|
name: "ix_program_subject_internship_subject_id",
|
||||||
table: "program_subject",
|
table: "program_subject",
|
||||||
@ -451,7 +452,7 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
name: "internship_subject");
|
name: "internship_subject");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "internship");
|
name: "internships");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "editions");
|
name: "editions");
|
@ -218,21 +218,21 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("Id")
|
||||||
.HasName("pk_internship");
|
.HasName("pk_internships");
|
||||||
|
|
||||||
b.HasIndex("EditionId")
|
b.HasIndex("EditionId")
|
||||||
.HasName("ix_internship_edition_id");
|
.HasName("ix_internships_edition_id");
|
||||||
|
|
||||||
b.HasIndex("InternshipRegistrationId")
|
b.HasIndex("InternshipRegistrationId")
|
||||||
.HasName("ix_internship_internship_registration_id");
|
.HasName("ix_internships_internship_registration_id");
|
||||||
|
|
||||||
b.HasIndex("ReportId")
|
b.HasIndex("ReportId")
|
||||||
.HasName("ix_internship_report_id");
|
.HasName("ix_internships_report_id");
|
||||||
|
|
||||||
b.HasIndex("StudentId")
|
b.HasIndex("StudentId")
|
||||||
.HasName("ix_internship_student_id");
|
.HasName("ix_internships_student_id");
|
||||||
|
|
||||||
b.ToTable("internship");
|
b.ToTable("internships");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
||||||
@ -267,6 +267,10 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
.HasColumnName("state")
|
.HasColumnName("state")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("SubmissionDate")
|
||||||
|
.HasColumnName("submission_date")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<long?>("TypeId")
|
b.Property<long?>("TypeId")
|
||||||
.HasColumnName("type_id")
|
.HasColumnName("type_id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
@ -544,7 +548,7 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
|
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
|
||||||
.WithMany("Documentation")
|
.WithMany("Documentation")
|
||||||
.HasForeignKey("InternshipId")
|
.HasForeignKey("InternshipId")
|
||||||
.HasConstraintName("fk_document_internship_internship_id");
|
.HasConstraintName("fk_document_internships_internship_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
||||||
@ -570,22 +574,22 @@ namespace InternshipSystem.Repository.Migrations
|
|||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
||||||
.WithMany("Internships")
|
.WithMany("Internships")
|
||||||
.HasForeignKey("EditionId")
|
.HasForeignKey("EditionId")
|
||||||
.HasConstraintName("fk_internship_editions_edition_id");
|
.HasConstraintName("fk_internships_editions_edition_id");
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
.HasForeignKey("InternshipRegistrationId")
|
||||||
.HasConstraintName("fk_internship_internship_registration_internship_registration_");
|
.HasConstraintName("fk_internships_internship_registration_internship_registration");
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Report", "Report")
|
b.HasOne("InternshipSystem.Core.Report", "Report")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("ReportId")
|
.HasForeignKey("ReportId")
|
||||||
.HasConstraintName("fk_internship_report_report_id");
|
.HasConstraintName("fk_internships_report_report_id");
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Student", "Student")
|
b.HasOne("InternshipSystem.Core.Student", "Student")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("StudentId")
|
.HasForeignKey("StudentId")
|
||||||
.HasConstraintName("fk_internship_students_student_id");
|
.HasConstraintName("fk_internships_students_student_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
||||||
|
Loading…
Reference in New Issue
Block a user