Compare commits
2 Commits
master
...
Internship
Author | SHA1 | Date | |
---|---|---|---|
655b084c96 | |||
296075a3b4 |
@ -1,4 +1,9 @@
|
|||||||
BUILD_PATH=$1
|
BUILD_PATH=$1
|
||||||
|
|
||||||
cd $BUILD_PATH/src || exit 1
|
cd $BUILD_PATH/src || exit 1
|
||||||
|
|
||||||
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
|
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
|
||||||
|
|
||||||
|
cd $BUILD_PATH/.docker || exit 1
|
||||||
|
|
||||||
|
docker-compose up -d --build --force-recreate
|
@ -7,14 +7,8 @@ services:
|
|||||||
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=szwoniu"
|
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=szwoniu"
|
||||||
ASPNETCORE_ENVIRONMENT: Development
|
ASPNETCORE_ENVIRONMENT: Development
|
||||||
ASPNETCORE_URLS: http://+:80
|
ASPNETCORE_URLS: http://+:80
|
||||||
SECURITYOPTIONS__SECRET: iewaiwie3aig9wi3chieBai9eephai
|
SECURITYOPTIONS__SECRET: PDv7DrqznYL6nv7DrqzjnQYO9JxIsWdcjnQYL6nu0f
|
||||||
SECURITYOPTIONS__EXPIRATION: 1440 # 24h in minutes
|
SECURITYOPTIONS__EXPIRATION: 20
|
||||||
SECURITYOPTIONS__BASEURL: https://logowanie.pg.edu.pl
|
|
||||||
SECURITYOPTIONS__TOKENPATH: /oauth2.0/accessToken
|
|
||||||
SECURITYOPTIONS__PROFILEPATH: /oauth2.0/profile
|
|
||||||
SECURITYOPTIONS__CLIENTID: PraktykiClientId
|
|
||||||
SECURITYOPTIONS__REDIRECTURL: https://system-praktyk.stg.kadet.net/user/login/check/pg
|
|
||||||
FILLER__USE_DEFAULT_DATA: "true"
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- db.postgres
|
- db.postgres
|
||||||
ports:
|
ports:
|
||||||
|
@ -1,867 +0,0 @@
|
|||||||
{
|
|
||||||
"info": {
|
|
||||||
"_postman_id": "f0858747-6271-4176-9193-ed1f9be0d7d3",
|
|
||||||
"name": "StudentOperations",
|
|
||||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
||||||
},
|
|
||||||
"item": [
|
|
||||||
{
|
|
||||||
"name": "loginDev",
|
|
||||||
"request": {
|
|
||||||
"method": "GET",
|
|
||||||
"header": [],
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/dev/login",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"dev",
|
|
||||||
"login"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetInternshipManagementList",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
|
|
||||||
"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=Asc",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"internship"
|
|
||||||
],
|
|
||||||
"query": [
|
|
||||||
{
|
|
||||||
"key": "OrderByField",
|
|
||||||
"value": "InternshipState"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "SortOrder",
|
|
||||||
"value": "Asc"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetInternshipManagement",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
|
|
||||||
"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.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"type": "text",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "\"\""
|
|
||||||
},
|
|
||||||
"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.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"type": "text",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "\"Co żeś odrąbał andzeju\""
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/internship/reject/1",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"internship",
|
|
||||||
"reject",
|
|
||||||
"1"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "loginEdition",
|
|
||||||
"request": {
|
|
||||||
"method": "POST",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTUyLCJleHAiOjE2MDEyODM5NTEsImlhdCI6MTYwMTE5NzU1Mn0.0wcNQSXV55MFvEnRLC09nGwCqI7M2kuWdwe0EOV_C6Y",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "application/json",
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "\"138da8a3-855c-4b17-9bd2-5f357679efa9\""
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/access/loginEdition",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"access",
|
|
||||||
"loginEdition"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "currentInternship",
|
|
||||||
"request": {
|
|
||||||
"method": "GET",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "application/json",
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/internshipRegistration",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"internshipRegistration"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetCourseList",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"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/course",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"course"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetCourse",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"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/course/1",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"course",
|
|
||||||
"1"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CreateCourse",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\r\n \"id\": null,\r\n \"name\": \"testowy\",\r\n \"nameEng\": \"test\"\r\n}"
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/course",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"course"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "UpdateCourse",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\r\n \"id\": 3,\r\n \"name\": \"testowyUp\",\r\n \"nameEng\": \"testUp\"\r\n}"
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/course",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"course"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "DeleteCourse",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "DELETE",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"type": "text",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/course/3",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"course",
|
|
||||||
"3"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetEditionManagementListByCourse",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"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/editions?course=1",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"editions"
|
|
||||||
],
|
|
||||||
"query": [
|
|
||||||
{
|
|
||||||
"key": "course",
|
|
||||||
"value": "1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetEditionManagementList",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"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/editions",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"editions"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetEditionManagement",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA0ODI3ODgzLCJleHAiOjE2MDQ5MTQyODMsImlhdCI6MTYwNDgyNzg4M30.a3mMm3Zk3xpfsmIwlqtpjgWgTNEXv8O4hH_V_L9UFZo",
|
|
||||||
"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/editions/138da8a3-855c-4b17-9bd2-5f357679efa9",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"editions",
|
|
||||||
"138da8a3-855c-4b17-9bd2-5f357679efa9"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CreateEdition",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\r\n \"editionStart\": \"2020-11-15T11:02:04.002Z\",\r\n \"editionFinish\": \"2020-11-25T11:02:04.002Z\",\r\n \"reportingStart\": \"2020-11-20T11:02:04.002Z\",\r\n \"course\": {\r\n \"id\": 1,\r\n \"name\": \"Informatyka\",\r\n \"nameEng\": \"Informatics\"\r\n },\r\n \"availableSubjectsIds\": [2],\r\n \"availableInternshipTypesIds\": [8]\r\n}"
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/edition",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"edition"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "UpdateEdition",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\r\n \"id\": \"138da8a3-855c-4b17-9bd2-5f357679efa9\",\r\n \"editionStart\": \"2020-11-15T11:02:04.002Z\",\r\n \"editionFinish\": \"2020-11-20T11:02:04.002Z\",\r\n \"reportingStart\": \"2020-11-17T11:02:04.002Z\",\r\n \"course\": {\r\n \"id\": 2,\r\n \"name\": \"Inżynieria Biomedyczna\",\r\n \"nameEng\": \"Biomedical Engineering\"\r\n },\r\n \"availableSubjectsIds\": [3],\r\n \"availableInternshipTypesIds\": [3]\r\n}"
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/editions",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"editions"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "DeleteEditionManagement",
|
|
||||||
"request": {
|
|
||||||
"auth": {
|
|
||||||
"type": "bearer",
|
|
||||||
"bearer": [
|
|
||||||
{
|
|
||||||
"key": "token",
|
|
||||||
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA0ODI3ODgzLCJleHAiOjE2MDQ5MTQyODMsImlhdCI6MTYwNDgyNzg4M30.a3mMm3Zk3xpfsmIwlqtpjgWgTNEXv8O4hH_V_L9UFZo",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"method": "DELETE",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"type": "text",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"type": "text",
|
|
||||||
"value": "application/json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/management/editions/be1a4439-0360-477c-85c5-e28bc8542883",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"management",
|
|
||||||
"editions",
|
|
||||||
"be1a4439-0360-477c-85c5-e28bc8542883"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "updateRegistration",
|
|
||||||
"request": {
|
|
||||||
"method": "PUT",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "application/json",
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\r\n \"company\": {\r\n \"id\": 1,\r\n \"nip\": null,\r\n \"name\": null\r\n },\r\n \"branchOffice\": {\r\n \"id\": 1,\r\n \"street\": null,\r\n \"building\": null,\r\n \"city\": null,\r\n \"postalCode\": null,\r\n \"country\": null\r\n },\r\n \"start\": \"2020-07-27T09:43:49.094Z\",\r\n \"end\": \"2020-09-27T09:43:49.094Z\",\r\n \"type\": {\r\n \"id\": 2,\r\n \"type\": null,\r\n \"description\": null,\r\n \"descriptionEng\": null\r\n }\r\n}"
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/internshipRegistration",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"internshipRegistration"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetRegisteredEditions",
|
|
||||||
"request": {
|
|
||||||
"method": "GET",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "application/json",
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/editions",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"editions"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "GetEditionsConfiguration",
|
|
||||||
"request": {
|
|
||||||
"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/editions/138da8a3-855c-4b17-9bd2-5f357679efa9",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"editions",
|
|
||||||
"138da8a3-855c-4b17-9bd2-5f357679efa9"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "RegisterForEdition",
|
|
||||||
"request": {
|
|
||||||
"method": "POST",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Authorization",
|
|
||||||
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "application/json",
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "\"138da8a3-855c-4b17-9bd2-5f357679efa9\""
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8080/register",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8080",
|
|
||||||
"path": [
|
|
||||||
"register"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
49
README.MD
49
README.MD
@ -1,49 +0,0 @@
|
|||||||
# Uruchomienie
|
|
||||||
|
|
||||||
Aby uruchomić środowisko deweloperskie wystarczy
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
|
|
||||||
docker-compose -f ./.docker/docker-compose.yaml --build --volumes
|
|
||||||
```
|
|
||||||
|
|
||||||
# Opis struktury
|
|
||||||
|
|
||||||
Opis struktury projektu
|
|
||||||
|
|
||||||
## src/
|
|
||||||
|
|
||||||
zawiera kod podzielony na 3 projekty
|
|
||||||
|
|
||||||
- Api - Definicja interfejsu wystawianego dla częsci frontendowej
|
|
||||||
- Core - Logika biznesowa aplikacji, definicja domeny.
|
|
||||||
- Repository - Definicja repozytorium EFCore
|
|
||||||
|
|
||||||
## test/
|
|
||||||
|
|
||||||
Zawiera testy jednostkowe projektu. Przy pisaniu wykorzystano Machine-Specification
|
|
||||||
|
|
||||||
## .build/
|
|
||||||
|
|
||||||
Folder zawierający pliki definiujące CI/CD projektu
|
|
||||||
|
|
||||||
## .docker/
|
|
||||||
|
|
||||||
Folder zawiera pliki docker-compose przeznaczone do uruchamiania środowiska deweloperskiego, stanowiące również dokumentacje zmiennych środowiskowych konfigurujących projekt
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=password"
|
|
||||||
ASPNETCORE_ENVIRONMENT: Development
|
|
||||||
ASPNETCORE_URLS: http://+:80
|
|
||||||
SECURITYOPTIONS__SECRET: secret
|
|
||||||
SECURITYOPTIONS__EXPIRATION: 1440 # 24h in minutes
|
|
||||||
SECURITYOPTIONS__BASEURL: https://logowanie.pg.edu.pl
|
|
||||||
SECURITYOPTIONS__TOKENPATH: /oauth2.0/accessToken
|
|
||||||
SECURITYOPTIONS__PROFILEPATH: /oauth2.0/profile
|
|
||||||
SECURITYOPTIONS__CLIENTID: PraktykiClientId
|
|
||||||
SECURITYOPTIONS__REDIRECTURL: https://system-praktyk.net/user/login/check/pg
|
|
||||||
```
|
|
||||||
|
|
||||||
## props/
|
|
||||||
|
|
||||||
Folder ze współdzieloną konfiguracją dla grup projektów, np. wersji bibliotek używanych przy pisaniu testów.
|
|
5
global.json
Normal file
5
global.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "3.1.301"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public static class AuthenticationBuilderExtension
|
||||||
|
{
|
||||||
|
public static AuthenticationBuilder AddMyGut(this AuthenticationBuilder builder) =>
|
||||||
|
builder.AddMyGut(MyGutAuthenticationDefaults.AuthenticationScheme, MyGutAuthenticationDefaults.DisplayName, options => { });
|
||||||
|
|
||||||
|
public static AuthenticationBuilder AddMyGut(
|
||||||
|
this AuthenticationBuilder builder,
|
||||||
|
string scheme,
|
||||||
|
string caption,
|
||||||
|
Action<MyGutAuthenticationOptions> configuration
|
||||||
|
) =>
|
||||||
|
builder.AddOAuth<MyGutAuthenticationOptions, MyGutAuthenticationHandler>(scheme, caption, configuration);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public static class MyGutAuthenticationConstants
|
||||||
|
{
|
||||||
|
public static class Urls
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Claims
|
||||||
|
{
|
||||||
|
public const string AlbumNumber = "urn:mygut:albumnumber";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UrlQueryParameterValues
|
||||||
|
{
|
||||||
|
public const string Consent = "consent";
|
||||||
|
public const string None = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public static class MyGutAuthenticationDefaults
|
||||||
|
{
|
||||||
|
public const string AuthenticationScheme = "MyGut";
|
||||||
|
|
||||||
|
public const string DisplayName = "MyGut";
|
||||||
|
|
||||||
|
public const string Issuer = "MyGut";
|
||||||
|
|
||||||
|
public const string CallbackPath = "/signin-mygut";
|
||||||
|
|
||||||
|
public const string AuthorizationEndpoint = "https://logowanie.pg.edu.pl/login";
|
||||||
|
|
||||||
|
public const string TokenEndpoint = "https://logowanie.pg.edu.pl/login";
|
||||||
|
|
||||||
|
public const string UserInformationEndpoint = "https://logowanie.pg.edu.pl/login";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public class MyGutAuthenticationHandler : OAuthHandler<MyGutAuthenticationOptions>
|
||||||
|
{
|
||||||
|
public MyGutAuthenticationHandler(
|
||||||
|
IOptionsMonitor<MyGutAuthenticationOptions> options,
|
||||||
|
ILoggerFactory logger,
|
||||||
|
UrlEncoder encoder,
|
||||||
|
ISystemClock clock) : base(options, logger, encoder, clock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||||
|
|
||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public class MyGutAuthenticationOptions : OAuthOptions
|
||||||
|
{
|
||||||
|
public MyGutAuthenticationOptions()
|
||||||
|
{
|
||||||
|
ClaimsIssuer = MyGutAuthenticationDefaults.Issuer;
|
||||||
|
CallbackPath = MyGutAuthenticationDefaults.CallbackPath;
|
||||||
|
AuthorizationEndpoint = MyGutAuthenticationDefaults.AuthorizationEndpoint;
|
||||||
|
TokenEndpoint = MyGutAuthenticationDefaults.TokenEndpoint;
|
||||||
|
UserInformationEndpoint = MyGutAuthenticationDefaults.UserInformationEndpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@ using AutoMapper;
|
|||||||
using InternshipSystem.Api.Queries;
|
using InternshipSystem.Api.Queries;
|
||||||
using InternshipSystem.Api.Result;
|
using InternshipSystem.Api.Result;
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Core;
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
@ -20,26 +19,9 @@ namespace InternshipSystem.Api
|
|||||||
result => result.Status,
|
result => result.Status,
|
||||||
opt => opt.MapFrom(edition => edition.IsOpen ? "Open" : "Archival"));
|
opt => opt.MapFrom(edition => edition.IsOpen ? "Open" : "Archival"));
|
||||||
|
|
||||||
CreateMap<Edition, EditionManagementResult>();
|
|
||||||
|
|
||||||
CreateMap<Edition, EditionDetailsResult>();
|
|
||||||
|
|
||||||
CreateMap<Edition, EditionConfigurationResult>();
|
CreateMap<Edition, EditionConfigurationResult>();
|
||||||
|
|
||||||
CreateMap<InternshipSubject, InternshipSubject>();
|
CreateMap<EditionSubject, InternshipSubject>().IncludeMembers(es => es.Subject);
|
||||||
|
|
||||||
CreateMap<EditionSubject, InternshipSubject>()
|
|
||||||
.IncludeMembers(es => es.Subject);
|
|
||||||
|
|
||||||
CreateMap<EditionInternshipType, InternshipType>()
|
|
||||||
.IncludeMembers(eit => eit.InternshipType);
|
|
||||||
|
|
||||||
CreateMap<ReportFieldEdition, ReportField>()
|
|
||||||
.IncludeMembers(e => e.Field);
|
|
||||||
|
|
||||||
CreateMap<ReportField, ReportField>();
|
|
||||||
|
|
||||||
CreateMap<InternshipType, InternshipType>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,53 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using IdentityServer4.Extensions;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Commands
|
|
||||||
{
|
|
||||||
public class UpdateRegistrationForm
|
|
||||||
{
|
|
||||||
public UpdateCompany? Company { get; set; }
|
|
||||||
public DateTime? Start { get; set; }
|
|
||||||
public DateTime? End { get; set; }
|
|
||||||
public UpdateMentor? Mentor { get; set; }
|
|
||||||
public List<long> Subjects { get; set; }
|
|
||||||
public int? Hours { get; set; }
|
|
||||||
public long? Type { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct UpdateMentor
|
|
||||||
{
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
public string Email { get; set; }
|
|
||||||
public string PhoneNumber { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct UpdateCompany
|
|
||||||
{
|
|
||||||
public long? Id { get; set; }
|
|
||||||
public string Nip { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public UpdateBranchOffice? BranchOffice { get; set; }
|
|
||||||
|
|
||||||
public bool IsCustomUpdate => !Nip.IsNullOrEmpty() || !Name.IsNullOrEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct UpdateBranchOffice
|
|
||||||
{
|
|
||||||
public long? Id { get; set; }
|
|
||||||
public string Street { get; set; }
|
|
||||||
public string Building { get; set; }
|
|
||||||
public string City { get; set; }
|
|
||||||
public string PostalCode { get; set; }
|
|
||||||
public string Country { get; set; }
|
|
||||||
|
|
||||||
public bool IsCustomUpdate => !string.IsNullOrEmpty(Street) ||
|
|
||||||
!string.IsNullOrEmpty(Building) ||
|
|
||||||
!string.IsNullOrEmpty(City) ||
|
|
||||||
!string.IsNullOrEmpty(PostalCode) ||
|
|
||||||
!string.IsNullOrEmpty(Country);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Api.Options;
|
using InternshipSystem.Api.Options;
|
||||||
using InternshipSystem.Api.Security;
|
using InternshipSystem.Api.Security;
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -20,69 +19,32 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
{
|
{
|
||||||
private readonly InternshipDbContext _context;
|
private readonly InternshipDbContext _context;
|
||||||
private readonly JwtTokenService _tokenService;
|
private readonly JwtTokenService _tokenService;
|
||||||
private readonly GutCasClient _loginClient;
|
|
||||||
private readonly SecurityOptions _securityOptions;
|
private readonly SecurityOptions _securityOptions;
|
||||||
|
|
||||||
public AccessController(
|
public AccessController(IOptions<SecurityOptions> options, InternshipDbContext context, JwtTokenService tokenService)
|
||||||
IOptions<SecurityOptions> options,
|
|
||||||
InternshipDbContext context,
|
|
||||||
JwtTokenService tokenService,
|
|
||||||
GutCasClient loginClient)
|
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_tokenService = tokenService;
|
_tokenService = tokenService;
|
||||||
_loginClient = loginClient;
|
|
||||||
_securityOptions = options.Value;
|
_securityOptions = options.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost("login")]
|
[HttpGet("login")]
|
||||||
public async Task<ActionResult> Authenticate([FromBody] string code, CancellationToken cancellationToken)
|
public async Task<ActionResult> Authenticate(string code, CancellationToken cancellationToken)
|
||||||
{
|
|
||||||
var token = await _loginClient.GetCasTokenAsync(code, cancellationToken);
|
|
||||||
|
|
||||||
var casData = await _loginClient.GetProfileAsync(token, cancellationToken);
|
|
||||||
|
|
||||||
if (!long.TryParse(casData.PersonNumber, out var id))
|
|
||||||
{
|
|
||||||
return BadRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
var student = await _context.Students.FirstOrDefaultAsync(s => s.Id == id, cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (student == null)
|
|
||||||
{
|
|
||||||
student = CreateStudentWithCasData(casData);
|
|
||||||
await _context.Students.AddAsync(student, cancellationToken);
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
var identity = new ClaimsIdentity(new[]
|
|
||||||
{
|
|
||||||
new Claim(ClaimTypes.Name, student.FirstName),
|
|
||||||
new Claim(ClaimTypes.Surname, student.LastName),
|
|
||||||
new Claim(InternshipClaims.PersonNumber, student.Id.ToString())
|
|
||||||
});
|
|
||||||
|
|
||||||
return Ok(_tokenService.generateToken(identity));
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("/dev/login")]
|
|
||||||
public async Task<ActionResult> Authenticate(CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
var identity = new ClaimsIdentity(new[]
|
var identity = new ClaimsIdentity(new[]
|
||||||
{
|
{
|
||||||
new Claim(ClaimTypes.Name, "firstname"),
|
new Claim(ClaimTypes.Name, "Jan"),
|
||||||
new Claim(ClaimTypes.Surname, "lastname"),
|
new Claim(ClaimTypes.Surname, "Kowalski"),
|
||||||
new Claim(InternshipClaims.PersonNumber, "1")
|
new Claim(InternshipClaims.PersonNumber, "1")
|
||||||
});
|
});
|
||||||
|
|
||||||
return Ok(_tokenService.generateToken(identity));
|
return Ok(_tokenService.generateToken(identity));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("loginEdition")]
|
[HttpGet("loginEdition")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult> LoginIntoEdition([FromBody] Guid editionId, [FromServices] User user, CancellationToken token)
|
public async Task<ActionResult> LoginIntoEdition(Guid editionId, User user, CancellationToken token)
|
||||||
{
|
{
|
||||||
var edition = await _context.Editions.FindAsync(editionId);
|
var edition = await _context.Editions.FindAsync(editionId);
|
||||||
|
|
||||||
@ -102,16 +64,5 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
|
|
||||||
return Ok(_tokenService.generateToken(newIdentity));
|
return Ok(_tokenService.generateToken(newIdentity));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Student CreateStudentWithCasData(CasUserData casData)
|
|
||||||
{
|
|
||||||
var id = long.Parse(casData.PersonNumber);
|
|
||||||
var firstName = casData.FirstName;
|
|
||||||
var lastName = casData.LastName;
|
|
||||||
var email = casData.Mail.First(s => s.EndsWith("@student.pg.edu.pl"));
|
|
||||||
var albumNumber = int.Parse(casData.AlbumNumber);
|
|
||||||
|
|
||||||
return Student.CreateStudent(id, firstName, lastName, email, albumNumber);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -15,39 +16,24 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
public DatabaseFiller FillerService { get; }
|
public DatabaseFiller FillerService { get; }
|
||||||
|
|
||||||
|
|
||||||
// [HttpPost("fill")]
|
[HttpPost("fill")]
|
||||||
// public async Task<IActionResult> FillAll()
|
public async Task<IActionResult> Fill() {
|
||||||
// {
|
await FillerService.FillCompanies();
|
||||||
// await FillerService.FillAll();
|
await FillerService.FillEditions();
|
||||||
// return Ok();
|
return Ok();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// [HttpPost("fill/companies")]
|
[HttpPost("fill/companies")]
|
||||||
// public async Task<IActionResult> FillCompaniesAsync()
|
public async Task<IActionResult> FillCompaniesAsync()
|
||||||
// {
|
{
|
||||||
// await FillerService.FillCompanies();
|
await FillerService.FillCompanies();
|
||||||
// return Ok();
|
return Ok();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// [HttpPost("fill/internshipTypes")]
|
[HttpPost("fill/editions")]
|
||||||
// public async Task<IActionResult> FillInternshipTypesAsync()
|
public async Task<IActionResult> FillEditionsAsync() {
|
||||||
// {
|
await FillerService.FillEditions();
|
||||||
// await FillerService.FillInternshipTypes();
|
return Ok();
|
||||||
// return Ok();
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [HttpPost("fill/editions")]
|
|
||||||
// public async Task<IActionResult> FillEditionsAsync()
|
|
||||||
// {
|
|
||||||
// await FillerService.FillEditions();
|
|
||||||
// return Ok();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [HttpPost("fill/staticPages")]
|
|
||||||
// public async Task<IActionResult> FillStaticPagesAsync()
|
|
||||||
// {
|
|
||||||
// await FillerService.FillStaticPages();
|
|
||||||
// return Ok();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,15 +3,11 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Api.Queries;
|
using InternshipSystem.Api.Queries;
|
||||||
using InternshipSystem.Api.Queries.SearchQuery;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Core;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using static System.String;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
namespace InternshipSystem.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -23,24 +19,19 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InternshipDbContext Context { get; }
|
private InternshipDbContext Context { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get companies matching provided paginated query
|
/// Get companies matching provided paginated query
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="searchQuery">Paginated query description</param>
|
/// <param name="searchQuery">Paginated query description</param>
|
||||||
/// <response code="200">Successfully retrieved Companies</response>
|
|
||||||
/// <response code="400">Search query was malformed</response>
|
|
||||||
/// <returns>Part of companies collection</returns>
|
/// <returns>Part of companies collection</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[Authorize]
|
public async Task<IReadOnlyCollection<Company>> SearchByNameAsync([FromQuery] SearchQuery searchQuery, CancellationToken cancellationToken) =>
|
||||||
public async Task<ActionResult<IReadOnlyCollection<Company>>> SearchByNameAsync([FromQuery] CompanySearchQuery searchQuery, [FromServices] User user, CancellationToken cancellationToken) =>
|
|
||||||
await Context.Companies
|
await Context.Companies
|
||||||
.Where(c => c.Name.ToLower().Contains(searchQuery.Name.ToLower()))
|
.Where(c => c.Name.ToLower().Contains(searchQuery.Query.ToLower()))
|
||||||
.Where(c => c.Provider == 0 || c.Provider == user.PersonNumber)
|
|
||||||
.OrderBy(o => o.Name)
|
.OrderBy(o => o.Name)
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
.Skip(searchQuery.Page * searchQuery.PerPage)
|
||||||
.Take(searchQuery.PerPage)
|
.Take(searchQuery.PerPage)
|
||||||
@ -57,200 +48,18 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[HttpGet("{companyId}")]
|
[HttpGet("{companyId}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[Authorize]
|
public async Task<IReadOnlyCollection<BranchOffice>> SearchBranchesByAddress([FromQuery] SearchQuery searchQuery, long companyId, CancellationToken token)
|
||||||
public async Task<ActionResult<IReadOnlyCollection<BranchOffice>>> SearchBranchesByAddress([FromQuery] BranchOfficeSearchQuery searchQuery, long companyId, [FromServices] User user, CancellationToken token)
|
|
||||||
{
|
{
|
||||||
var company = await Context.Companies.Where(c => c.Id == companyId).FirstAsync(token);
|
var company = await Context.Companies.Where(c => c.Id == companyId).FirstAsync(token);
|
||||||
|
|
||||||
return await Context.Entry(company)
|
return await Context.Entry(company)
|
||||||
.Collection(c => c.Branches)
|
.Collection(c => c.Branches)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(office => office.Address.City.ToLower().Contains(searchQuery.City.ToLower()))
|
.Where(office => office.Address.City.Contains(searchQuery.Query.ToLower()))
|
||||||
.Where(office => office.Provider == 0 || office.Provider == user.PersonNumber)
|
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
.Skip(searchQuery.Page * searchQuery.PerPage)
|
||||||
.Take(searchQuery.PerPage)
|
.Take(searchQuery.PerPage)
|
||||||
.ToListAsync(token);
|
.ToListAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates or add new company (if not new than contains id)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="companyForm"></param>
|
|
||||||
/// <response code="200">Successfully updated company</response>
|
|
||||||
/// <response code="400">Company form was malformed</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Company not found</response>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> UpsertCompany([FromBody] CompanyForm companyForm, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var validator = new CompanyForm.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(companyForm, cancellationToken);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (companyForm.Id.HasValue)
|
|
||||||
{
|
|
||||||
var companyToUpdate = await Context.Companies.FindAsync(companyForm.Id.Value);
|
|
||||||
|
|
||||||
if (companyToUpdate == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
companyToUpdate.Name = IsNullOrEmpty(companyForm.Name) ? companyToUpdate.Name : companyForm.Name;
|
|
||||||
companyToUpdate.Nip = IsNullOrEmpty(companyForm.Nip) ? companyToUpdate.Nip : companyForm.Nip;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newCompany = Company.CreateCompany(companyForm.Nip, companyForm.Name);
|
|
||||||
await Context.Companies.AddAsync(newCompany, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deletes existing company by id
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="companyId"></param>
|
|
||||||
/// <response code="200">Successfully deleted company</response>
|
|
||||||
/// <response code="400">Company id is empty</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Company not found</response>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{companyId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> DeleteCompany(long companyId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var companyToDelete = await Context.Companies
|
|
||||||
.Include(c => c.Branches)
|
|
||||||
.FirstOrDefaultAsync(c => c.Id == companyId, cancellationToken);
|
|
||||||
|
|
||||||
if (companyToDelete == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
Context.Companies.Remove(companyToDelete);
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates or add new branchOffice (if not new than contains id)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="branchOfficeForm"></param>
|
|
||||||
/// <param name="companyId"></param>
|
|
||||||
/// <response code="200">Successfully updated company branch office</response>
|
|
||||||
/// <response code="400">Branch office was malformed</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Company or branch office not found</response>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("{companyId}/branchOffices")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> UpdateBranch([FromBody] BranchOfficeForm branchOfficeForm, long companyId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var validator = new BranchOfficeForm.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(branchOfficeForm, cancellationToken);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
var company = await Context.Companies
|
|
||||||
.Include(c => c.Branches)
|
|
||||||
.FirstOrDefaultAsync(c => c.Id == companyId, cancellationToken);
|
|
||||||
|
|
||||||
if (company == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (branchOfficeForm.Id.HasValue)
|
|
||||||
{
|
|
||||||
var branchOffice = company.Branches.First(b => b.Id == branchOfficeForm.Id);
|
|
||||||
|
|
||||||
if (branchOffice == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
branchOffice.Address.Country = IsNullOrEmpty(branchOfficeForm.Country) ? branchOffice.Address.Country : branchOfficeForm.Country;
|
|
||||||
branchOffice.Address.City = IsNullOrEmpty(branchOfficeForm.City) ? branchOffice.Address.City : branchOfficeForm.City;
|
|
||||||
branchOffice.Address.PostalCode = IsNullOrEmpty(branchOfficeForm.PostalCode) ? branchOffice.Address.PostalCode : branchOfficeForm.PostalCode;
|
|
||||||
branchOffice.Address.Street = IsNullOrEmpty(branchOfficeForm.Street) ? branchOffice.Address.Street : branchOfficeForm.Street;
|
|
||||||
branchOffice.Address.Building = IsNullOrEmpty(branchOfficeForm.Building) ? branchOffice.Address.Building : branchOfficeForm.Building;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newBranchOffice = new BranchOffice
|
|
||||||
{
|
|
||||||
Address = new BranchAddress
|
|
||||||
{
|
|
||||||
Country = branchOfficeForm.Country,
|
|
||||||
City = branchOfficeForm.City,
|
|
||||||
PostalCode = branchOfficeForm.PostalCode,
|
|
||||||
Street = branchOfficeForm.Street,
|
|
||||||
Building = branchOfficeForm.Building,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
company.Branches.Add(newBranchOffice);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deletes existing branchOffice
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="branchOfficeId"></param>
|
|
||||||
/// <response code="200">Successfully deleted company branch office</response>
|
|
||||||
/// <response code="400">Branch office id is empty</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Company or branch office not found</response>
|
|
||||||
[HttpDelete("{companyId}/branchOffice/{branchOfficeId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> DeleteBranch(long companyId, long branchOfficeId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var company =
|
|
||||||
await Context.Companies
|
|
||||||
.Include(c => c.Branches)
|
|
||||||
.Where(c => c.Id == companyId)
|
|
||||||
.FirstOrDefaultAsync(cancellationToken);
|
|
||||||
|
|
||||||
if (company == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var branchOffice = company.Branches.RemoveAll(b => b.Id == branchOfficeId);
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,127 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Queries;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
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/course")]
|
|
||||||
public class CourseController : ControllerBase
|
|
||||||
{
|
|
||||||
private InternshipDbContext Context { get; }
|
|
||||||
|
|
||||||
public CourseController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
Context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult<IReadOnlyCollection<Course>>> GetCourses(CancellationToken cancellationToken) =>
|
|
||||||
await Context.Courses
|
|
||||||
.ToListAsync(cancellationToken);
|
|
||||||
|
|
||||||
[HttpGet("{courseId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult<Course>> GetCourse(long courseId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var course = await Context.Courses
|
|
||||||
.Where(c => c.Id == courseId)
|
|
||||||
.FirstOrDefaultAsync(cancellationToken);
|
|
||||||
|
|
||||||
if (course == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(course);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> UpsertCourse([FromBody] CourseForm courseForm, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var validator = new CourseForm.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(courseForm, cancellationToken);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (courseForm.Id.HasValue)
|
|
||||||
{
|
|
||||||
var course = await Context.Courses.FindAsync(courseForm.Id.Value);
|
|
||||||
|
|
||||||
if (course == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
course.UpdateCourse(courseForm.Name, courseForm.NameEng);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newCourse = Course.CreateCourse(courseForm.Name, courseForm.NameEng);
|
|
||||||
|
|
||||||
await Context.Courses.AddAsync(newCourse, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("{courseId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> DeleteCourse(long courseId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var courseToDelete = await Context.Courses
|
|
||||||
.Where(c => c.Id == courseId)
|
|
||||||
.FirstOrDefaultAsync(cancellationToken);
|
|
||||||
|
|
||||||
if (courseToDelete == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var referencedEditions =
|
|
||||||
await Context.Editions
|
|
||||||
.Include(e => e.Course)
|
|
||||||
.Where(e => e.Course.Id == courseToDelete.Id)
|
|
||||||
.CountAsync(cancellationToken);
|
|
||||||
|
|
||||||
if (referencedEditions > 0)
|
|
||||||
{
|
|
||||||
return Conflict();
|
|
||||||
}
|
|
||||||
|
|
||||||
Context.Courses.Remove(courseToDelete);
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
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/document")]
|
|
||||||
public class DocumentManagementController : ControllerBase
|
|
||||||
{
|
|
||||||
private InternshipDbContext Context { get; }
|
|
||||||
|
|
||||||
public DocumentManagementController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
Context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("{documentId}/delete")]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> DeleteDocument(long documentId, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var internship = await Context.Internships
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), ct);
|
|
||||||
|
|
||||||
if (internship == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
internship.RemoveDocument(documentId);
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{documentId}/accept")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> AcceptDocument(long documentId, [FromBody] string comment, CancellationToken token)
|
|
||||||
{
|
|
||||||
var internship = await Context.Internships
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), token);
|
|
||||||
|
|
||||||
if (internship == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var document = internship.Documentation
|
|
||||||
.FirstOrDefault(d => d.Id.Equals(documentId));
|
|
||||||
|
|
||||||
if (document == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.State = DocumentState.Accepted;
|
|
||||||
document.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{documentId}/reject")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> RejectDocument(long documentId, [FromBody] string comment, CancellationToken token)
|
|
||||||
{
|
|
||||||
var internship = await Context.Internships
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), token);
|
|
||||||
|
|
||||||
if (internship == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var document = internship.Documentation
|
|
||||||
.FirstOrDefault(d => d.Id.Equals(documentId));
|
|
||||||
|
|
||||||
if (document == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.State = DocumentState.Rejected;
|
|
||||||
document.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,11 @@
|
|||||||
using System;
|
using System.Threading;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Mime;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Api.Queries;
|
using InternshipSystem.Api.Queries;
|
||||||
using InternshipSystem.Api.Security;
|
using InternshipSystem.Api.Security;
|
||||||
using InternshipSystem.Api.Service;
|
using InternshipSystem.Api.Services;
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
namespace InternshipSystem.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -20,19 +13,18 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[Route("document")]
|
[Route("document")]
|
||||||
public class DocumentsController : ControllerBase
|
public class DocumentsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly InternshipDbContext _context;
|
private readonly IInternshipService _internshipService;
|
||||||
private readonly FileValidator _fileValidator;
|
|
||||||
|
|
||||||
public DocumentsController(InternshipDbContext context, FileValidator fileValidator)
|
public DocumentsController(IInternshipService internshipService)
|
||||||
{
|
{
|
||||||
_context = context;
|
_internshipService = internshipService;
|
||||||
_fileValidator = fileValidator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fill out required document,
|
/// Fill out required document,
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="documentRequest">Documents Scan and description, and Id of filled document</param>
|
/// <param name="documentRequest">Documents Scan and description, and Id of filled document</param>
|
||||||
|
/// <returns></returns>
|
||||||
/// <response code="200">If change was successfully registered</response>
|
/// <response code="200">If change was successfully registered</response>
|
||||||
/// <response code="400">If the provided query was malformed</response>
|
/// <response code="400">If the provided query was malformed</response>
|
||||||
/// <response code="404">Id doesn't match any required document</response>
|
/// <response code="404">Id doesn't match any required document</response>
|
||||||
@ -43,139 +35,19 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||||
public async Task<ActionResult> AddDocumentToInternship(
|
public async Task<ActionResult> AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest, CancellationToken cancellationToken)
|
||||||
[FromBody] DocumentPublishRequest documentRequest,
|
|
||||||
[FromServices] User user,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
var validator = new DocumentPublishRequest.Validator();
|
var validator = new DocumentPublishRequest.Validator();
|
||||||
var result = await validator.ValidateAsync(documentRequest, cancellationToken);
|
var validationResult = await validator.ValidateAsync(documentRequest, cancellationToken);
|
||||||
|
|
||||||
if (!result.IsValid)
|
if (!validationResult.IsValid)
|
||||||
{
|
{
|
||||||
return BadRequest(result.ToString());
|
return BadRequest(validationResult.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
|
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
||||||
|
|
||||||
var internship =
|
return await _internshipService.AddDocumentToInternship(documentRequest, personNumber, cancellationToken);
|
||||||
await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
internship.AddNewDocument(documentRequest.Description, documentRequest.Type);
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
catch (ArgumentException e)
|
|
||||||
{
|
|
||||||
return BadRequest(e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(internship.Documentation.First(d => d.Type == documentRequest.Type));
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{documentId}/scan")]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult> AddDocumentScan(long documentId, IFormFile documentScan, [FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
await using var memoryStream = new MemoryStream();
|
|
||||||
await documentScan.CopyToAsync(memoryStream, cancellationToken);
|
|
||||||
|
|
||||||
if (!_fileValidator.IsValidFile(memoryStream.ToArray()))
|
|
||||||
{
|
|
||||||
return BadRequest("error.document.scan");
|
|
||||||
}
|
|
||||||
|
|
||||||
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
|
|
||||||
|
|
||||||
var internship =
|
|
||||||
await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
|
||||||
|
|
||||||
var document = await _context.Entry(internship)
|
|
||||||
.Collection(i => i.Documentation)
|
|
||||||
.Query()
|
|
||||||
.Include(d => d.Scan)
|
|
||||||
.FirstAsync(d => d.Id == documentId, cancellationToken);
|
|
||||||
|
|
||||||
document.Scan ??= new DocumentScan();
|
|
||||||
|
|
||||||
document.Scan.Size = memoryStream.Length;
|
|
||||||
document.Scan.Filename = documentScan.FileName;
|
|
||||||
document.Scan.Mime = _fileValidator.GetFileMime(memoryStream.ToArray());
|
|
||||||
document.Scan.File = memoryStream.ToArray();
|
|
||||||
|
|
||||||
document.State = DocumentState.Submitted;
|
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{documentId}/scan/download")]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult> GetDocumentScan(long documentId, [FromQuery] string disposition, [FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
|
|
||||||
|
|
||||||
var internship =
|
|
||||||
await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
|
||||||
|
|
||||||
var document =
|
|
||||||
await _context.Entry(internship)
|
|
||||||
.Collection(i => i.Documentation)
|
|
||||||
.Query()
|
|
||||||
.Include(d => d.Scan)
|
|
||||||
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
|
|
||||||
|
|
||||||
var stream = new MemoryStream(document.Scan.File);
|
|
||||||
|
|
||||||
Response.Headers.Add("Content-Disposition", new ContentDisposition
|
|
||||||
{
|
|
||||||
Inline = disposition == "inline",
|
|
||||||
FileName = document.Scan.Filename,
|
|
||||||
Size = document.Scan.Size
|
|
||||||
}.ToString());
|
|
||||||
|
|
||||||
return File(stream, document.Scan.Mime);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{documentId}/scan")]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult> GetDocumentScanData(long documentId, [FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
|
|
||||||
|
|
||||||
var internship =
|
|
||||||
await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
|
||||||
|
|
||||||
var scan =
|
|
||||||
await _context.Entry(internship)
|
|
||||||
.Collection(i => i.Documentation)
|
|
||||||
.Query()
|
|
||||||
.Include(d => d.Scan)
|
|
||||||
.Select(s => new {s.Id, s.Scan.Filename, s.Scan.Mime, s.Scan.Size})
|
|
||||||
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
|
|
||||||
|
|
||||||
if (scan == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(scan);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,13 +38,15 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult<IEnumerable<EditionResult>>> GetAvailableEditions([FromServices] User user, CancellationToken token)
|
public async Task<ActionResult<IList<EditionResult>>> GetAvailableEditions(CancellationToken token)
|
||||||
{
|
{
|
||||||
|
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
||||||
|
|
||||||
var editions =
|
var editions =
|
||||||
await Context.Editions
|
await Context.Editions
|
||||||
.Where(edition =>
|
.Where(edition =>
|
||||||
edition.Internships
|
edition.Internships
|
||||||
.Any(internship => internship.Student.Id == user.PersonNumber))
|
.Any(internship => internship.Student.Id == personNumber))
|
||||||
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
|
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
|
||||||
.ToListAsync(token);
|
.ToListAsync(token);
|
||||||
|
|
||||||
@ -57,52 +59,22 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get accessible editions
|
/// Get edition's configuration
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Editions accessible by the current user</response>
|
|
||||||
/// <response code="401">This action is only available for authorized student</response>
|
|
||||||
/// <response code="404"/>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
public async Task<ActionResult<EditionResult>> GetEditionInfo(Guid id, CancellationToken token)
|
|
||||||
{
|
|
||||||
var edition =
|
|
||||||
await Context.Editions
|
|
||||||
.Where(e => e.Id == id)
|
|
||||||
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
|
|
||||||
.FirstOrDefaultAsync(token);
|
|
||||||
|
|
||||||
if (edition == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(edition);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get current edition's configuration
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">Parameters of edition registered for by student</response>
|
/// <response code="200">Parameters of edition registered for by student</response>
|
||||||
/// <response code="401">This action is only available for authorized student registered for this edition edition</response>
|
/// <response code="401">This action is only available for authorized student registered for this edition edition</response>
|
||||||
/// <response code="404">Specified edition doesn't exist</response>
|
/// <response code="404">Specified edition doesn't exist</response>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("current")]
|
[HttpGet("{id}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||||
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration([FromServices] User user, CancellationToken token)
|
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration(Guid id, CancellationToken token)
|
||||||
{
|
{
|
||||||
var edition =
|
var edition =
|
||||||
await Context.Editions
|
await Context.Editions
|
||||||
.Include(e => e.AvailableSubjects)
|
.Include(e => e.AvailableSubjects)
|
||||||
.Include(e => e.ReportSchema)
|
.Where(e => e.Id == id)
|
||||||
.ThenInclude(e => e.Field)
|
|
||||||
.Include(e => e.Course)
|
|
||||||
.Where(e => e.Id == user.EditionId)
|
|
||||||
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
||||||
.FirstOrDefaultAsync(token);
|
.FirstOrDefaultAsync(token);
|
||||||
|
|
||||||
|
@ -1,168 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AutoMapper;
|
|
||||||
using AutoMapper.QueryableExtensions;
|
|
||||||
using InternshipSystem.Api.Queries;
|
|
||||||
using InternshipSystem.Api.Queries.SearchQuery;
|
|
||||||
using InternshipSystem.Api.Result;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
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/editions")]
|
|
||||||
public class EditionManagementController : ControllerBase
|
|
||||||
{
|
|
||||||
private InternshipDbContext Context { get; }
|
|
||||||
private IMapper Mapper { get; }
|
|
||||||
|
|
||||||
public EditionManagementController(IMapper mapper, InternshipDbContext context)
|
|
||||||
{
|
|
||||||
Context = context;
|
|
||||||
Mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult<IReadOnlyCollection<EditionManagementResult>>> GetEditions([FromQuery] EditionSearchQuery searchQuery, CancellationToken token) =>
|
|
||||||
await Context.Editions
|
|
||||||
.Include(e => e.Course)
|
|
||||||
.Where(p => !searchQuery.Course.HasValue || p.Course.Id == searchQuery.Course)
|
|
||||||
.ProjectTo<EditionManagementResult>(Mapper.ConfigurationProvider)
|
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
|
||||||
.Take(searchQuery.PerPage)
|
|
||||||
.ToListAsync(token);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("{editionId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult<EditionDetailsResult>> GetFullEdition(Guid editionId, CancellationToken token)
|
|
||||||
{
|
|
||||||
var edition = await Context.Editions
|
|
||||||
.Include(e => e.Course)
|
|
||||||
.Include(e => e.AvailableSubjects)
|
|
||||||
.ThenInclude(s => s.Subject)
|
|
||||||
.Include(e => e.AvailableInternshipTypes)
|
|
||||||
.ThenInclude(i => i.InternshipType)
|
|
||||||
.Include(e => e.ReportSchema)
|
|
||||||
.ThenInclude(er => er.Field)
|
|
||||||
.Where(e => e.Id == editionId)
|
|
||||||
.ProjectTo<EditionDetailsResult>(Mapper.ConfigurationProvider)
|
|
||||||
.FirstOrDefaultAsync(token);
|
|
||||||
|
|
||||||
if (edition == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(edition);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> UpsertEdition(EditionForm editionForm, CancellationToken token)
|
|
||||||
{
|
|
||||||
var validator = new EditionForm.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(editionForm, token);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editionForm.Id.HasValue)
|
|
||||||
{
|
|
||||||
var editionToUpdate = await Context.Editions
|
|
||||||
.Include(e => e.AvailableSubjects)
|
|
||||||
.Include(e => e.AvailableInternshipTypes)
|
|
||||||
.Include(e => e.ReportSchema)
|
|
||||||
.FirstOrDefaultAsync(e => e.Id == editionForm.Id.Value, token);
|
|
||||||
|
|
||||||
if (editionToUpdate == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
editionToUpdate.UpdateEdition(editionForm.EditionStart, editionForm.EditionFinish, editionForm.ReportingStart,
|
|
||||||
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
|
|
||||||
|
|
||||||
if (!editionToUpdate.IsValidDates)
|
|
||||||
{
|
|
||||||
return BadRequest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newEdition =
|
|
||||||
Edition.CreateEdition(editionForm.EditionStart.Value, editionForm.EditionFinish.Value, editionForm.ReportingStart.Value,
|
|
||||||
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
|
|
||||||
|
|
||||||
if (!newEdition.IsValidDates)
|
|
||||||
{
|
|
||||||
return BadRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.Editions.AddAsync(newEdition, token);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("{editionId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> DeleteEdition(Guid editionId, CancellationToken token)
|
|
||||||
{
|
|
||||||
var editionToDelete = await Context.Editions
|
|
||||||
.Include(e => e.AvailableSubjects)
|
|
||||||
.Include(e => e.AvailableInternshipTypes)
|
|
||||||
.Include(e => e.ReportSchema)
|
|
||||||
.FirstOrDefaultAsync(e => e.Id.Equals(editionId), token);
|
|
||||||
|
|
||||||
if (editionToDelete == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var referencedInternships =
|
|
||||||
await Context
|
|
||||||
.Entry(editionToDelete)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.CountAsync(token);
|
|
||||||
|
|
||||||
if (referencedInternships > 0)
|
|
||||||
{
|
|
||||||
return Conflict();
|
|
||||||
}
|
|
||||||
|
|
||||||
Context.Editions.Remove(editionToDelete);
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
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("internship")]
|
|
||||||
public class InternshipController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly InternshipDbContext _context;
|
|
||||||
|
|
||||||
public InternshipController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get internship for current edition
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">If current internship returned successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized student registered for current edition</response>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult<Internship>> GetCurrentEditionInternship([FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var edition = await _context.Editions
|
|
||||||
.FindAsync(user.EditionId);
|
|
||||||
|
|
||||||
var internship = await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.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.Report)
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.SingleAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
|
||||||
|
|
||||||
return Ok(internship);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,190 +0,0 @@
|
|||||||
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.InternshipRegistration.Type)
|
|
||||||
.Include(i => i.Student)
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.Include(i => i.Report)
|
|
||||||
.Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id == searchQuery.EditionId)
|
|
||||||
.Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State == searchQuery.InternshipState)
|
|
||||||
.Where(i => !searchQuery.InternshipState.HasValue || i.Report.State == searchQuery.ReportState)
|
|
||||||
.Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber == 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()))
|
|
||||||
.Where(i => !searchQuery.DocumentWithState.HasValue || i.Documentation.Any(d => d.State == searchQuery.DocumentWithState))
|
|
||||||
.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{internshipId}/status")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> GetInternshipStatus(long internshipId, CancellationToken token)
|
|
||||||
{
|
|
||||||
var internship = await Context.Internships
|
|
||||||
.Include(i => i.InternshipRegistration)
|
|
||||||
.Include(i => i.Report)
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
|
|
||||||
|
|
||||||
if (internship == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new JsonResult(new { Errors = internship.ValidateStatus() });
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{internshipId}/grade")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> GradeInternship(long internshipId, [FromBody] float grade, CancellationToken token)
|
|
||||||
{
|
|
||||||
var internship = await Context.Internships
|
|
||||||
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
|
|
||||||
|
|
||||||
if (internship == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
internship.Grade = grade;
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
|
|
||||||
return new JsonResult(new { Errors = internship.ValidateStatus() });
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{internshipId}/registration/accept")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> AcceptInternshipRegistration(long internshipId, [FromBody] string comment, 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;
|
|
||||||
internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("{internshipId}/registration/reject")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> RejectInternshipRegistration(long internshipId, [FromBody] string comment, 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;
|
|
||||||
internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(token);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +1,28 @@
|
|||||||
using System;
|
using System.Threading;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Api.Commands;
|
using InternshipSystem.Api.Queries;
|
||||||
using InternshipSystem.Api.Security;
|
using InternshipSystem.Api.Security;
|
||||||
using InternshipSystem.Api.UseCases;
|
using InternshipSystem.Api.Services;
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
namespace InternshipSystem.Api.Controllers
|
||||||
{
|
{
|
||||||
[ApiController]
|
|
||||||
[Route("internshipRegistration")]
|
[Route("internshipRegistration")]
|
||||||
public class InternshipRegistrationController : ControllerBase
|
public class InternshipRegistrationController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly InternshipDbContext _context;
|
private readonly IInternshipService _internshipService;
|
||||||
|
|
||||||
public InternshipRegistrationController(InternshipDbContext dbContext)
|
public InternshipRegistrationController(IInternshipService internshipService)
|
||||||
{
|
{
|
||||||
_context = dbContext;
|
_internshipService = internshipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validate and add filled internship registration form
|
/// Validate and add filled internship registration form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="registrationQuery">Internship registration data</param>
|
||||||
/// <response code="200">If registration form was successfully added</response>
|
/// <response code="200">If registration form was successfully added</response>
|
||||||
/// <response code="400">If the provided registration query was malformed</response>
|
/// <response code="400">If the provided registration query was malformed</response>
|
||||||
/// <response code="401">This action is only available for authorized student registered for current edition</response>
|
/// <response code="401">This action is only available for authorized student registered for current edition</response>
|
||||||
@ -34,52 +30,21 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
[Authorize]
|
||||||
public async Task<ActionResult> SubmitRegistrationForm(
|
public async Task<ActionResult> SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery,
|
||||||
[FromBody] UpdateRegistrationForm registrationCommand,
|
|
||||||
[FromServices] User user,
|
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var edition = await _context.Editions
|
var validator = new RegistrationFormQuery.Validator();
|
||||||
.Include(e => e.AvailableInternshipTypes)
|
var validationResult = await validator.ValidateAsync(registrationQuery, cancellationToken);
|
||||||
.ThenInclude(t => t.InternshipType)
|
|
||||||
.Include(e => e.AvailableSubjects)
|
|
||||||
.ThenInclude(t => t.Subject)
|
|
||||||
.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
|
|
||||||
|
|
||||||
var internship =
|
if (!validationResult.IsValid)
|
||||||
await _context
|
|
||||||
.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.Include(i => i.InternshipRegistration)
|
|
||||||
.ThenInclude(r => r.BranchAddress)
|
|
||||||
.Include(i => i.InternshipRegistration)
|
|
||||||
.ThenInclude(r => r.Company)
|
|
||||||
.Include(i => i.InternshipRegistration)
|
|
||||||
.ThenInclude(c => c.Company.Branches)
|
|
||||||
.Include(i => i.InternshipRegistration)
|
|
||||||
.ThenInclude(c => c.Type)
|
|
||||||
.Include(i => i.InternshipRegistration)
|
|
||||||
.ThenInclude(c => c.Subjects)
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.Where(i => i.Student.Id == user.PersonNumber)
|
|
||||||
.FirstAsync(cancellationToken);
|
|
||||||
|
|
||||||
var useCase = new UpdateInternshipRegistrationUseCase(_context, internship, edition, user);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var (status, result) = await useCase.UpdateInternshipRegistration(registrationCommand, cancellationToken);
|
return BadRequest(validationResult.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
||||||
|
|
||||||
return new JsonResult(new {Status = status, Errors = result});
|
return await _internshipService.SubmitRegistration(registrationQuery, personNumber, cancellationToken);
|
||||||
}
|
|
||||||
catch (ArgumentException e)
|
|
||||||
{
|
|
||||||
return BadRequest(e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,171 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Queries;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
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("internshipTypes")]
|
|
||||||
public class InternshipTypesController : ControllerBase
|
|
||||||
{
|
|
||||||
private InternshipDbContext Context { get; }
|
|
||||||
|
|
||||||
public InternshipTypesController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
Context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get internship types available for current edition
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>List of internship types for current edition</returns>
|
|
||||||
[HttpGet("current")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult<IEnumerable<InternshipType>>> GetInternshipTypesForEdition([FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var edition =
|
|
||||||
await Context.Editions
|
|
||||||
.Include(e => e.AvailableInternshipTypes)
|
|
||||||
.ThenInclude(e => e.InternshipType)
|
|
||||||
.Where(e => e.Id.Equals(user.EditionId))
|
|
||||||
.FirstOrDefaultAsync(cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (edition == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(edition.AvailableInternshipTypes.Select(e => e.InternshipType));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get internship type by id
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Internship type</returns>
|
|
||||||
/// <response code="200">Internship type returned successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Internship type not found</response>
|
|
||||||
[HttpGet("{internshipTypeId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult<InternshipType>> GetInternshipType(long internshipTypeId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return await Context.InternshipTypes.FindAsync(internshipTypeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get internship type list
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Internship type</returns>
|
|
||||||
/// <response code="200">Internship type list returned successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult<IEnumerable<InternshipType>>> SearchInternshipTypes([FromQuery] InternshipTypeSearchQuery searchQuery, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return await Context.InternshipTypes
|
|
||||||
.Where(t => string.IsNullOrEmpty(searchQuery.Label) || t.Label.Contains(searchQuery.Label))
|
|
||||||
.Where(t => string.IsNullOrEmpty(searchQuery.LabelEng) || t.Label.Contains(searchQuery.LabelEng))
|
|
||||||
.OrderBy(t => t.Label)
|
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
|
||||||
.Take(searchQuery.PerPage)
|
|
||||||
.ToListAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add or update internship type, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Internship type updated successfully</response>
|
|
||||||
/// <response code="400">Invalid internship type form</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Internship type with selected id do not exist</response>
|
|
||||||
[HttpPut]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> UpsertInternshipType([FromBody] InternshipTypeFrom internshipTypeFrom, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var validator = new InternshipTypeFrom.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(internshipTypeFrom, cancellationToken);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internshipTypeFrom.Id.HasValue)
|
|
||||||
{
|
|
||||||
var internshipType = await Context.InternshipTypes.FindAsync(internshipTypeFrom.Id.Value);
|
|
||||||
|
|
||||||
if (internshipType == null)
|
|
||||||
{
|
|
||||||
return NotFound($"Internship type with id {internshipTypeFrom.Id} not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
internshipType.Label = string.IsNullOrEmpty(internshipTypeFrom.Label) ? internshipType.Label : internshipTypeFrom.Label;
|
|
||||||
internshipType.LabelEng = string.IsNullOrEmpty(internshipTypeFrom.LabelEng) ? internshipType.LabelEng : internshipTypeFrom.LabelEng;
|
|
||||||
internshipType.Description = string.IsNullOrEmpty(internshipTypeFrom.Description) ? internshipType.Description : internshipTypeFrom.Description;
|
|
||||||
internshipType.DescriptionEng = string.IsNullOrEmpty(internshipTypeFrom.DescriptionEng) ? internshipType.DescriptionEng : internshipTypeFrom.DescriptionEng;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var newInternshipType = new InternshipType
|
|
||||||
{
|
|
||||||
Label = internshipTypeFrom.Label,
|
|
||||||
LabelEng = internshipTypeFrom.LabelEng,
|
|
||||||
Description = internshipTypeFrom.Description,
|
|
||||||
DescriptionEng = internshipTypeFrom.DescriptionEng,
|
|
||||||
};
|
|
||||||
|
|
||||||
await Context.InternshipTypes.AddAsync(newInternshipType, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add or update internship type
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Internship type deleted successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Internship type with selected id do not exist</response>
|
|
||||||
[HttpDelete("{internshipTypeId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> DeleteInternshipType(long internshipTypeId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var internshipTypeToDelete = await Context.InternshipTypes
|
|
||||||
.FirstOrDefaultAsync(t => t.Id.Equals(internshipTypeId), cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (internshipTypeToDelete == null)
|
|
||||||
{
|
|
||||||
return NotFound($"Internship type with id: {internshipTypeId} does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
Context.InternshipTypes.Remove(internshipTypeToDelete);
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok($"Internship type with id: {internshipTypeId} deleted successfully");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,6 @@ using InternshipSystem.Repository;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
namespace InternshipSystem.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -34,31 +33,24 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode, [FromServices] User user, CancellationToken token)
|
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode, CancellationToken token)
|
||||||
{
|
{
|
||||||
var edition = await _context.Editions
|
var edition = await _context.Editions.FindAsync(registrationCode, token);
|
||||||
.Include(e => e.Internships)
|
|
||||||
.ThenInclude(i => i.Student)
|
|
||||||
.FirstOrDefaultAsync(e => e.Id.Equals(registrationCode), cancellationToken: token);
|
|
||||||
|
|
||||||
if (edition == null)
|
if (edition == null)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var student = await _context.Students.FindAsync(user.PersonNumber);
|
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
||||||
|
|
||||||
|
var student = await _context.Students.FindAsync(personNumber, token);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
edition.RegisterInternship(student);
|
edition.RegisterInternship(student);
|
||||||
await _context.SaveChangesAsync(token);
|
await _context.SaveChangesAsync(token);
|
||||||
}
|
|
||||||
catch (ArgumentException e)
|
|
||||||
{
|
|
||||||
return BadRequest(e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,62 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core.ValueObject;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
[Route("internship/report")]
|
|
||||||
public class ReportController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly InternshipDbContext _context;
|
|
||||||
|
|
||||||
public ReportController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult> PostReport([FromBody] JObject reportValue, [FromServices] User user, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var edition = await _context.Editions
|
|
||||||
.FindAsync(user.EditionId);
|
|
||||||
|
|
||||||
var internship = await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.Include(i => i.Report)
|
|
||||||
.Include(i => i.Documentation)
|
|
||||||
.SingleAsync(i => i.Student.Id == user.PersonNumber, ct);
|
|
||||||
|
|
||||||
internship.Report.UpdateReport(reportValue.ToString(Formatting.None));
|
|
||||||
internship.AddNewDocument("", DocumentType.InternshipEvaluation);
|
|
||||||
|
|
||||||
await _context.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
|
||||||
public async Task<ActionResult> GetReport([FromServices] User user, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var edition = await _context.Editions
|
|
||||||
.FindAsync(user.EditionId);
|
|
||||||
|
|
||||||
var internship = await _context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.Include(i => i.Report)
|
|
||||||
.SingleAsync(i => i.Student.Id == user.PersonNumber, ct);
|
|
||||||
|
|
||||||
return Ok(JsonConvert.DeserializeObject(internship.Report.Value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AutoMapper;
|
|
||||||
using InternshipSystem.Api.Queries.SearchQuery;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
[Route("management/report")]
|
|
||||||
public class ReportFieldsController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly InternshipDbContext _context;
|
|
||||||
private readonly IMapper _mapper;
|
|
||||||
|
|
||||||
public ReportFieldsController(InternshipDbContext context, IMapper mapper)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
_mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("fields")]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<IEnumerable<ReportField>> GetFields(FieldSearchQuery searchQuery, CancellationToken ct) =>
|
|
||||||
await _context.ReportFields
|
|
||||||
.Where(c => c.Label.ToLower().Contains(searchQuery.Label.ToLower()))
|
|
||||||
.OrderBy(o => o.Label)
|
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
|
||||||
.Take(searchQuery.PerPage)
|
|
||||||
.ToListAsync(ct);
|
|
||||||
|
|
||||||
[HttpPost("fields")]
|
|
||||||
[Authorize(Policy = Policies.IsOverseer)]
|
|
||||||
public async Task<ActionResult> CreateField([FromBody] FieldCreateRequest request, CancellationToken ct)
|
|
||||||
{
|
|
||||||
ReportField field;
|
|
||||||
|
|
||||||
switch (request.FieldType)
|
|
||||||
{
|
|
||||||
case FieldType.LongText:
|
|
||||||
case FieldType.ShortText:
|
|
||||||
field = new ReportField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType);
|
|
||||||
break;
|
|
||||||
case FieldType.Select:
|
|
||||||
case FieldType.Radial:
|
|
||||||
case FieldType.Checkbox:
|
|
||||||
field = new ReportChoiceField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType, request.Choices);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return BadRequest("Unknown field type");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _context.ReportFields.AddAsync(field, ct);
|
|
||||||
await _context.SaveChangesAsync(ct);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return BadRequest("Failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FieldSearchQuery : SearchQuery
|
|
||||||
{
|
|
||||||
public string Label { get; set; } = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FieldCreateRequest
|
|
||||||
{
|
|
||||||
public long? Id { get; set; }
|
|
||||||
public string Label { get; set; }
|
|
||||||
public string LabelEng { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public string DescriptionEng { get; set; }
|
|
||||||
public FieldType FieldType { get; set; }
|
|
||||||
public string[] Choices { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,163 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Queries;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("staticPage")]
|
|
||||||
public class StaticPagesController : ControllerBase
|
|
||||||
{
|
|
||||||
public StaticPagesController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
Context = context;
|
|
||||||
}
|
|
||||||
private InternshipDbContext Context { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get all static pages, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>List of static pages with titles and content</returns>
|
|
||||||
/// <response code="200">Static pages list returned successfully</response>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
public async Task<ActionResult<IList<StaticPage>>> GetStaticPages(CancellationToken cancellationToken) =>
|
|
||||||
await Context.StaticPages
|
|
||||||
.ToListAsync(cancellationToken);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get static page, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="accessName">Name of page</param>
|
|
||||||
/// <returns>Static page title and content</returns>
|
|
||||||
/// <response code="200">Static page returned successfully</response>
|
|
||||||
/// <response code="404">Static page with given access name do not exist</response>
|
|
||||||
[HttpGet("{accessName}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
public async Task<ActionResult<StaticPage>> GetStaticPage(string accessName, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var page =
|
|
||||||
await Context.StaticPages
|
|
||||||
.Where(p => p.AccessName.Trim().ToLower().Equals(accessName.Trim().ToLower()))
|
|
||||||
.FirstOrDefaultAsync(cancellationToken);
|
|
||||||
|
|
||||||
if (page == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add or update static page, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Static page updated successfully</response>
|
|
||||||
/// <response code="400">Static page form is not valid</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Static page with given id do not exist</response>
|
|
||||||
[HttpPut]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> UpdateStaticPage([FromBody] StaticPageForm staticPageForm, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var validator = new StaticPageForm.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(staticPageForm, cancellationToken);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (staticPageForm.Id.HasValue)
|
|
||||||
{
|
|
||||||
var pageToUpdate = await Context.StaticPages.FindAsync(staticPageForm.Id);
|
|
||||||
|
|
||||||
if (pageToUpdate == null)
|
|
||||||
{
|
|
||||||
return NotFound($"Static page with id: {staticPageForm.Id} does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(staticPageForm.AccessName))
|
|
||||||
{
|
|
||||||
var pageWithSameAccessName = await Context.StaticPages
|
|
||||||
.FirstOrDefaultAsync(sp => sp.AccessName.ToLower().Trim().Equals(staticPageForm.AccessName.ToLower().Trim()), cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (pageWithSameAccessName != null && !pageWithSameAccessName.Id.Equals(pageToUpdate.Id))
|
|
||||||
{
|
|
||||||
return BadRequest($"Static page with access name: {staticPageForm.AccessName} already exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pageToUpdate.AccessName = string.IsNullOrEmpty(staticPageForm.AccessName) ? pageToUpdate.AccessName : staticPageForm.AccessName;
|
|
||||||
pageToUpdate.Title = string.IsNullOrEmpty(staticPageForm.Title) ? pageToUpdate.Title : staticPageForm.Title;
|
|
||||||
pageToUpdate.TitleEng = string.IsNullOrEmpty(staticPageForm.TitleEng) ? pageToUpdate.TitleEng : staticPageForm.TitleEng;
|
|
||||||
pageToUpdate.Content = string.IsNullOrEmpty(staticPageForm.Content) ? pageToUpdate.Content : staticPageForm.Content;
|
|
||||||
pageToUpdate.ContentEng = string.IsNullOrEmpty(staticPageForm.ContentEng) ? pageToUpdate.ContentEng : staticPageForm.ContentEng;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var pageWithSameAccessName = await Context.StaticPages
|
|
||||||
.FirstOrDefaultAsync(sp => sp.AccessName.ToLower().Trim().Equals(staticPageForm.AccessName.ToLower().Trim()), cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (pageWithSameAccessName != null)
|
|
||||||
{
|
|
||||||
return BadRequest($"Static page with access name: {staticPageForm.AccessName} already exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newStaticPage = new StaticPage
|
|
||||||
{
|
|
||||||
AccessName = staticPageForm.AccessName.ToLower().Trim(),
|
|
||||||
Title = staticPageForm.Title,
|
|
||||||
TitleEng = staticPageForm.TitleEng,
|
|
||||||
Content = staticPageForm.Content,
|
|
||||||
ContentEng = staticPageForm.ContentEng,
|
|
||||||
};
|
|
||||||
await Context.StaticPages.AddAsync(newStaticPage, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
|
|
||||||
return Ok($"Static page updated successfully");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete static page, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Static page deleted successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Static page with given access name do not exist</response>
|
|
||||||
[HttpDelete("{accessName}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> DeleteStaticPage(string accessName, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var pageToDelete = await Context.StaticPages
|
|
||||||
.FirstOrDefaultAsync(sp => sp.AccessName.ToLower().Trim().Equals(accessName.ToLower().Trim()), cancellationToken: cancellationToken);
|
|
||||||
|
|
||||||
if (pageToDelete == null)
|
|
||||||
{
|
|
||||||
return NotFound($"Static page with access name: {accessName} does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
Context.StaticPages.Remove(pageToDelete);
|
|
||||||
await Context.SaveChangesAsync(cancellationToken);
|
|
||||||
return Ok($"Static page with access name: {accessName} deleted successfully");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,143 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Queries;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
[Route("students")]
|
|
||||||
[ApiController]
|
|
||||||
public class StudentsController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly InternshipDbContext _context;
|
|
||||||
|
|
||||||
public StudentsController(InternshipDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get current student personal data
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Current student data</returns>
|
|
||||||
/// <response code="200">Current student data returned successfully</response>
|
|
||||||
/// <response code="401">his action is only available for authorized student</response>
|
|
||||||
[HttpGet("current")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult<Student>> GetCurrentStudentData([FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return await _context.Students.FindAsync(user.PersonNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update current student personal data
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Current student data updated successfully</response>
|
|
||||||
/// <response code="401">his action is only available for authorized student</response>
|
|
||||||
[HttpPut("current")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> UpdateCurrentStudentData([FromBody] CurrentStudentForm studentNewData, [FromServices] User user, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var currentStudent = await _context.Students.FindAsync(user.PersonNumber);
|
|
||||||
|
|
||||||
currentStudent.AlbumNumber = studentNewData.AlbumNumber ?? currentStudent.AlbumNumber;
|
|
||||||
currentStudent.FirstName = string.IsNullOrEmpty(studentNewData.FirstName) ? currentStudent.FirstName : studentNewData.FirstName;
|
|
||||||
currentStudent.LastName = string.IsNullOrEmpty(studentNewData.LastName) ? currentStudent.LastName : studentNewData.LastName;
|
|
||||||
currentStudent.Email = string.IsNullOrEmpty(studentNewData.Email) ? currentStudent.Email : studentNewData.Email;
|
|
||||||
currentStudent.Course = string.IsNullOrEmpty(studentNewData.Course) ? currentStudent.Course : studentNewData.Course;
|
|
||||||
currentStudent.Semester = studentNewData.Semester ?? currentStudent.Semester;
|
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get student personal data, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Student personal data</returns>
|
|
||||||
/// <response code="200">Student data returned successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Student with given id do not exist</response>
|
|
||||||
[HttpGet("{studentPersonNumber}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult<Student>> GetStudentByPersonNumber(long studentPersonNumber, CancellationToken cancellationToken) =>
|
|
||||||
await _context.Students.FindAsync(studentPersonNumber);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Search students personal data, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>List of students personal data</returns>
|
|
||||||
/// <response code="200">List of student data</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult<IReadOnlyCollection<Student>>> SearchStudents([FromQuery] StudentSearchQuery searchQuery, CancellationToken cancellationToken) =>
|
|
||||||
await _context.Students
|
|
||||||
.Where(s => !searchQuery.AlbumNumber.HasValue || s.AlbumNumber.Equals(searchQuery.AlbumNumber))
|
|
||||||
.Where(s => string.IsNullOrEmpty(searchQuery.FirstName) || s.FirstName.ToLower().Contains(searchQuery.FirstName.ToLower()))
|
|
||||||
.Where(s => string.IsNullOrEmpty(searchQuery.LastName) || s.LastName.ToLower().Contains(searchQuery.LastName.ToLower()))
|
|
||||||
.OrderBy(s => s.AlbumNumber)
|
|
||||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
|
||||||
.Take(searchQuery.PerPage)
|
|
||||||
.ToListAsync(cancellationToken);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates student personal data, only available for coordinator
|
|
||||||
/// </summary>
|
|
||||||
/// <response code="200">Student data updated successfully</response>
|
|
||||||
/// <response code="401">This action is only available for authorized internship admin</response>
|
|
||||||
/// <response code="404">Student with given id do not exist</response>
|
|
||||||
[HttpPut("{studentId}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ActionResult> UpdateStudentData(long studentId, [FromBody] StudentForm studentNewData, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var validator = new StudentForm.Validator();
|
|
||||||
var validationResult = await validator.ValidateAsync(studentNewData, cancellationToken);
|
|
||||||
|
|
||||||
if (!validationResult.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(validationResult.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentStudent = await _context.Students.FindAsync(studentId);
|
|
||||||
|
|
||||||
if (currentStudent == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentStudent.AlbumNumber = studentNewData.AlbumNumber ?? currentStudent.AlbumNumber;
|
|
||||||
currentStudent.FirstName = string.IsNullOrEmpty(studentNewData.FirstName) ? currentStudent.FirstName : studentNewData.FirstName;
|
|
||||||
currentStudent.LastName = string.IsNullOrEmpty(studentNewData.LastName) ? currentStudent.LastName : studentNewData.LastName;
|
|
||||||
currentStudent.Email = string.IsNullOrEmpty(studentNewData.Email) ? currentStudent.Email : studentNewData.Email;
|
|
||||||
currentStudent.Course = string.IsNullOrEmpty(studentNewData.Course) ? currentStudent.Course : studentNewData.Course;
|
|
||||||
currentStudent.Semester = studentNewData.Semester ?? currentStudent.Semester;
|
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Converters
|
|
||||||
{
|
|
||||||
public class StringArrayConverter<TItem> : JsonConverter
|
|
||||||
{
|
|
||||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
var token = JToken.Load(reader);
|
|
||||||
|
|
||||||
if (token.Type == JTokenType.Array)
|
|
||||||
{
|
|
||||||
return token.ToObject<List<TItem>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new List<TItem>
|
|
||||||
{
|
|
||||||
token.ToObject<TItem>()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanConvert(Type objectType)
|
|
||||||
{
|
|
||||||
return objectType == typeof(List<TItem>);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanWrite => false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Extensions
|
|
||||||
{
|
|
||||||
public static class ApplicationBuilderExtensions
|
|
||||||
{
|
|
||||||
public static IApplicationBuilder UseMigration(this IApplicationBuilder app)
|
|
||||||
{
|
|
||||||
bool done = false;
|
|
||||||
while (!done)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
|
||||||
using var context = serviceScope.ServiceProvider.GetService<InternshipDbContext>();
|
|
||||||
|
|
||||||
context.Database.Migrate();
|
|
||||||
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IApplicationBuilder UseDefaultData(this IApplicationBuilder app, bool useDefaultData)
|
|
||||||
{
|
|
||||||
using var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
|
||||||
using var context = serviceScope.ServiceProvider.GetService<InternshipDbContext>();
|
|
||||||
var filler = serviceScope.ServiceProvider.GetService<DatabaseFiller>();
|
|
||||||
|
|
||||||
context.Database.Migrate();
|
|
||||||
if (useDefaultData && !context.Editions.Any())
|
|
||||||
{
|
|
||||||
filler.FillAll().Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using InternshipSystem.Api.Options;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using JsonConverter = System.Text.Json.Serialization.JsonConverter;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
public class GutCasClient
|
|
||||||
{
|
|
||||||
private readonly HttpClient _client;
|
|
||||||
private readonly SecurityOptions _securityOptions;
|
|
||||||
|
|
||||||
public GutCasClient(HttpClient client, IOptions<SecurityOptions> options)
|
|
||||||
{
|
|
||||||
_securityOptions = options.Value;
|
|
||||||
|
|
||||||
client.BaseAddress = _securityOptions.BaseUrl;
|
|
||||||
_client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> GetCasTokenAsync(string code, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var request = new HttpRequestMessage
|
|
||||||
{
|
|
||||||
Method = HttpMethod.Post,
|
|
||||||
Content = new FormUrlEncodedContent(new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "grant_type", "authorization_code" },
|
|
||||||
{ "client_id", _securityOptions.ClientId },
|
|
||||||
{ "client_secret", _securityOptions.Secret },
|
|
||||||
{ "redirect_uri", _securityOptions.RedirectUrl.ToString() },
|
|
||||||
{ "code", code }
|
|
||||||
}),
|
|
||||||
RequestUri = _securityOptions.TokenPath
|
|
||||||
};
|
|
||||||
|
|
||||||
var response = await _client.SendAsync(request, cancellationToken);
|
|
||||||
var content = await response.Content.ReadAsStringAsync();
|
|
||||||
|
|
||||||
var value = JsonConvert.DeserializeObject<Dictionary<string, object>>(content);
|
|
||||||
|
|
||||||
return value["access_token"].ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<CasUserData> GetProfileAsync(string token, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var request = new HttpRequestMessage
|
|
||||||
{
|
|
||||||
Method = HttpMethod.Get,
|
|
||||||
Content = new StringContent(string.Empty),
|
|
||||||
RequestUri = _securityOptions.ProfilePath
|
|
||||||
};
|
|
||||||
|
|
||||||
request.Headers.Authorization = AuthenticationHeaderValue.Parse($"Bearer {token}");
|
|
||||||
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
|
|
||||||
|
|
||||||
var response = await _client.SendAsync(request, cancellationToken);
|
|
||||||
var content = await response.Content.ReadAsStringAsync();
|
|
||||||
|
|
||||||
var result = JsonConvert.DeserializeObject<CasUserProfile>(content);
|
|
||||||
|
|
||||||
return result.Attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,19 +12,18 @@
|
|||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
|
||||||
<PackageReference Include="FluentValidation" Version="9.1.2" />
|
<PackageReference Include="FluentValidation" Version="9.1.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.6" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
|
||||||
<PackageReference Include="Serilog" Version="2.9.0" />
|
<PackageReference Include="Serilog" Version="2.9.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.6.3" />
|
|
||||||
<PackageReference Include="IdentityServer4" Version="3.1.4" />
|
<PackageReference Include="IdentityServer4" Version="3.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../InternshipSystem.Core/InternshipSystem.Core.csproj" />
|
<ProjectReference Include="../InternshipSystem.Core/InternshipSystem.Core.csproj" />
|
||||||
<ProjectReference Include="../InternshipSystem.Repository/InternshipSystem.Repository.csproj" />
|
<ProjectReference Include="../InternshipSystem.Repository/InternshipSystem.Repository.csproj" />
|
||||||
|
<ProjectReference Include="..\AspNet.Security.OAuth.MyGut\AspNet.Security.OAuth.MyGut.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -23,18 +23,11 @@ namespace InternshipSystem.Api.ModelBinders
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid? editionGuid = null;
|
|
||||||
if (principal.FindFirst(InternshipClaims.Edition) != null
|
|
||||||
&& Guid.TryParse(principal.FindFirst(InternshipClaims.Edition).Value, out var edition))
|
|
||||||
{
|
|
||||||
editionGuid = edition;
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = new User
|
var user = new User
|
||||||
{
|
{
|
||||||
Name = principal.FindFirst(ClaimTypes.Name).Value,
|
Name = principal.FindFirst(ClaimTypes.Name).Value,
|
||||||
PersonNumber = long.Parse(principal.FindFirst(InternshipClaims.PersonNumber).Value),
|
PersonNumber = long.Parse(principal.FindFirst(InternshipClaims.PersonNumber).Value),
|
||||||
EditionId = editionGuid
|
EditionId = Guid.TryParse(principal.FindFirst(InternshipClaims.Edition).Value, out var edition) ? edition : (Guid?) null
|
||||||
};
|
};
|
||||||
|
|
||||||
bindingContext.Result = ModelBindingResult.Success(user);
|
bindingContext.Result = ModelBindingResult.Success(user);
|
||||||
|
@ -1,21 +1,8 @@
|
|||||||
using System;
|
namespace InternshipSystem.Api.Options
|
||||||
using System.Security.Policy;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Options
|
|
||||||
{
|
{
|
||||||
public class SecurityOptions
|
public class SecurityOptions
|
||||||
{
|
{
|
||||||
public string Secret { get; set; }
|
public string Secret { get; set; }
|
||||||
public double Expiration { get; set; }
|
public double Expiration { get; set; }
|
||||||
|
|
||||||
public Uri BaseUrl { get; set; }
|
|
||||||
|
|
||||||
public Uri TokenPath { get; set; }
|
|
||||||
|
|
||||||
public Uri ProfilePath { get; set; }
|
|
||||||
|
|
||||||
public Uri RedirectUrl { get; set; }
|
|
||||||
|
|
||||||
public string ClientId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using Serilog.Formatting.Compact;
|
||||||
|
|
||||||
namespace InternshipSystem.Api
|
namespace InternshipSystem.Api
|
||||||
{
|
{
|
||||||
|
@ -17,18 +17,18 @@ namespace InternshipSystem.Api.Queries
|
|||||||
{
|
{
|
||||||
RuleFor(b => b.Id).NotNull()
|
RuleFor(b => b.Id).NotNull()
|
||||||
.When(c =>
|
.When(c =>
|
||||||
string.IsNullOrEmpty(c.Country) || string.IsNullOrEmpty(c.City) ||
|
!string.IsNullOrEmpty(c.Country) || !string.IsNullOrEmpty(c.City) ||
|
||||||
string.IsNullOrEmpty(c.PostalCode) || string.IsNullOrEmpty(c.Street) ||
|
!string.IsNullOrEmpty(c.PostalCode) || !string.IsNullOrEmpty(c.Street) ||
|
||||||
string.IsNullOrEmpty(c.Building));
|
!string.IsNullOrEmpty(c.Building));
|
||||||
RuleFor(b => b.Country).NotEmpty()
|
RuleFor(b => b.Country).NotNull()
|
||||||
.When(b => !b.Id.HasValue);
|
.When(b => !b.Id.HasValue);
|
||||||
RuleFor(b => b.City).NotEmpty()
|
RuleFor(b => b.City).NotNull()
|
||||||
.When(b => !b.Id.HasValue);
|
.When(b => !b.Id.HasValue);
|
||||||
RuleFor(b => b.PostalCode).NotEmpty()
|
RuleFor(b => b.PostalCode).NotNull()
|
||||||
.When(b => !b.Id.HasValue);
|
.When(b => !b.Id.HasValue);
|
||||||
RuleFor(b => b.Street).NotEmpty()
|
RuleFor(b => b.Street).NotNull()
|
||||||
.When(b => !b.Id.HasValue);
|
.When(b => !b.Id.HasValue);
|
||||||
RuleFor(b => b.Building).NotEmpty()
|
RuleFor(b => b.Building).NotNull()
|
||||||
.When(b => !b.Id.HasValue);
|
.When(b => !b.Id.HasValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace InternshipSystem.Api.Queries
|
|||||||
public Validator()
|
public Validator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Id).NotNull()
|
RuleFor(c => c.Id).NotNull()
|
||||||
.When(c => string.IsNullOrEmpty(c.Nip) || string.IsNullOrEmpty(c.Name));
|
.When(c => !string.IsNullOrEmpty(c.Nip) || !string.IsNullOrEmpty(c.Name));
|
||||||
RuleFor(c => c.Nip).NotEmpty()
|
RuleFor(c => c.Nip).NotEmpty()
|
||||||
.When(c => !c.Id.HasValue);
|
.When(c => !c.Id.HasValue);
|
||||||
RuleFor(c => c.Name).NotEmpty()
|
RuleFor(c => c.Name).NotEmpty()
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Queries
|
|
||||||
{
|
|
||||||
public class CourseForm
|
|
||||||
{
|
|
||||||
public long? Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string NameEng { get; set; }
|
|
||||||
|
|
||||||
public class Validator : AbstractValidator<CourseForm>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(c => c.Id).NotNull()
|
|
||||||
.When(c => string.IsNullOrWhiteSpace(c.Name));
|
|
||||||
|
|
||||||
RuleFor(c => c.Name).NotEmpty()
|
|
||||||
.When(c => !c.Id.HasValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace InternshipSystem.Api.Queries
|
|
||||||
{
|
|
||||||
public class CurrentStudentForm
|
|
||||||
{
|
|
||||||
public int? AlbumNumber { get; set; }
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
public string Email { get; set; }
|
|
||||||
public string Course { get; set; }
|
|
||||||
public int? Semester { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +1,22 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using InternshipSystem.Core.ValueObject;
|
using InternshipSystem.Core.ValueObject;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Queries
|
namespace InternshipSystem.Api.Queries
|
||||||
{
|
{
|
||||||
public class DocumentPublishRequest
|
public class DocumentPublishRequest
|
||||||
{
|
{
|
||||||
|
public long? Id { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
public byte[] Scan { get; set; }
|
||||||
public DocumentType Type { get; set; }
|
public DocumentType Type { get; set; }
|
||||||
|
|
||||||
public class Validator : AbstractValidator<DocumentPublishRequest>
|
public class Validator : AbstractValidator<DocumentPublishRequest>
|
||||||
{
|
{
|
||||||
|
public Validator()
|
||||||
|
{
|
||||||
|
RuleFor(document => document.Scan).NotEmpty();
|
||||||
|
RuleFor(document => document.Type).NotEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using FluentValidation;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Queries
|
|
||||||
{
|
|
||||||
public class EditionForm
|
|
||||||
{
|
|
||||||
public Guid? Id { get; set; }
|
|
||||||
public DateTime? EditionStart { get; set; }
|
|
||||||
public DateTime? EditionFinish { get; set; }
|
|
||||||
public DateTime? ReportingStart { get; set; }
|
|
||||||
public Course Course { get; set; }
|
|
||||||
public List<long> AvailableSubjectsIds { get; set; } = new List<long>();
|
|
||||||
public List<long> AvailableInternshipTypesIds { get; set; } = new List<long>();
|
|
||||||
public List<long> ReportSchema { get; set; } = new List<long>();
|
|
||||||
|
|
||||||
public class Validator : AbstractValidator<EditionForm>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(e => e.Id).NotNull()
|
|
||||||
.When(e => !e.EditionStart.HasValue || !e.EditionFinish.HasValue
|
|
||||||
|| !e.ReportingStart.HasValue || e.Course == null);
|
|
||||||
|
|
||||||
RuleFor(e => e.EditionStart).NotEmpty()
|
|
||||||
.When(e => !e.Id.HasValue);
|
|
||||||
RuleFor(e => e.EditionFinish).NotEmpty()
|
|
||||||
.When(e => !e.Id.HasValue);
|
|
||||||
RuleFor(e => e.ReportingStart).NotEmpty()
|
|
||||||
.When(e => !e.Id.HasValue);
|
|
||||||
RuleFor(e => e.Course).NotNull()
|
|
||||||
.When(e => !e.Id.HasValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Queries
|
|
||||||
{
|
|
||||||
public class InternshipTypeFrom
|
|
||||||
{
|
|
||||||
public long? Id { get; set; }
|
|
||||||
public string Label { get; set; }
|
|
||||||
public string LabelEng { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public string DescriptionEng { get; set; }
|
|
||||||
|
|
||||||
public class Validator : AbstractValidator<InternshipTypeFrom>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(t => t.Id).NotNull()
|
|
||||||
.When(t =>
|
|
||||||
string.IsNullOrEmpty(t.Label) || string.IsNullOrEmpty(t.LabelEng));
|
|
||||||
RuleFor(t => t.Label).NotEmpty()
|
|
||||||
.When(t => !t.Id.HasValue);
|
|
||||||
RuleFor(t => t.LabelEng).NotEmpty()
|
|
||||||
.When(t => !t.Id.HasValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ namespace InternshipSystem.Api.Queries
|
|||||||
public BranchOfficeForm BranchOffice { get; set; }
|
public BranchOfficeForm BranchOffice { get; set; }
|
||||||
public DateTime? Start { get; set; }
|
public DateTime? Start { get; set; }
|
||||||
public DateTime? End { get; set; }
|
public DateTime? End { get; set; }
|
||||||
public InternshipType Type { get; set; }
|
public InternshipType? Type { get; set; }
|
||||||
|
|
||||||
public class Validator : AbstractValidator<RegistrationFormQuery>
|
public class Validator : AbstractValidator<RegistrationFormQuery>
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
namespace InternshipSystem.Api.Queries.SearchQuery
|
namespace InternshipSystem.Api.Queries
|
||||||
{
|
{
|
||||||
public class SearchQuery
|
public class SearchQuery
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Value against which collection will be queried
|
||||||
|
/// </summary>
|
||||||
|
public string Query { get; set; } = "";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Which part of the collections to retrieve
|
/// Which part of the collections to retrieve
|
||||||
/// </summary>
|
/// </summary>
|
@ -1,9 +0,0 @@
|
|||||||
using InternshipSystem.Api.Queries.SearchQuery;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
public class BranchOfficeSearchQuery : SearchQuery
|
|
||||||
{
|
|
||||||
public string City { get; set; } = "";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace InternshipSystem.Api.Queries.SearchQuery
|
|
||||||
{
|
|
||||||
public class CompanySearchQuery : SearchQuery
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Value against which collection will be queried
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; } = "";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace InternshipSystem.Api.Queries.SearchQuery
|
|
||||||
{
|
|
||||||
public class EditionSearchQuery : SearchQuery
|
|
||||||
{
|
|
||||||
public long? Course { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
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 DocumentState? ReportState { get; set; }
|
|
||||||
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;
|
|
||||||
|
|
||||||
public DocumentState? DocumentWithState { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
using InternshipSystem.Api.Queries.SearchQuery;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
public class InternshipTypeSearchQuery : SearchQuery
|
|
||||||
{
|
|
||||||
public string Label { get; set; } = "";
|
|
||||||
public string LabelEng { get; set; } = "";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace InternshipSystem.Api.Queries.SearchQuery
|
|
||||||
{
|
|
||||||
public enum SortOrder
|
|
||||||
{
|
|
||||||
Asc,
|
|
||||||
Desc,
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using InternshipSystem.Api.Queries.SearchQuery;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
public class StudentSearchQuery : SearchQuery
|
|
||||||
{
|
|
||||||
public int? AlbumNumber { get; set; }
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Queries
|
|
||||||
{
|
|
||||||
public class StaticPageForm
|
|
||||||
{
|
|
||||||
public long? Id { get; set; }
|
|
||||||
public string AccessName { get; set; }
|
|
||||||
public string Title { get; set; }
|
|
||||||
public string TitleEng { get; set; }
|
|
||||||
public string Content { get; set; }
|
|
||||||
public string ContentEng { get; set; }
|
|
||||||
|
|
||||||
public class Validator : AbstractValidator<StaticPageForm>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(sp => sp.Id).NotNull()
|
|
||||||
.When(sp =>
|
|
||||||
string.IsNullOrEmpty(sp.AccessName) || string.IsNullOrEmpty(sp.Title) ||
|
|
||||||
string.IsNullOrEmpty(sp.TitleEng) || string.IsNullOrEmpty(sp.Content) ||
|
|
||||||
string.IsNullOrEmpty(sp.ContentEng));
|
|
||||||
RuleFor(sp => sp.AccessName).NotEmpty()
|
|
||||||
.When(sp => !sp.Id.HasValue);
|
|
||||||
RuleFor(sp => sp.Title).NotEmpty()
|
|
||||||
.When(sp => !sp.Id.HasValue);
|
|
||||||
RuleFor(sp => sp.TitleEng).NotEmpty()
|
|
||||||
.When(sp => !sp.Id.HasValue);
|
|
||||||
RuleFor(sp => sp.Content).NotEmpty()
|
|
||||||
.When(sp => !sp.Id.HasValue);
|
|
||||||
RuleFor(sp => sp.ContentEng).NotEmpty()
|
|
||||||
.When(sp => !sp.Id.HasValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using FluentValidation;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Queries
|
|
||||||
{
|
|
||||||
public class StudentForm
|
|
||||||
{
|
|
||||||
public int? AlbumNumber { get; set; }
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
public string Email { get; set; }
|
|
||||||
public string Course { get; set; }
|
|
||||||
public int? Semester { get; set; }
|
|
||||||
|
|
||||||
public class Validator : AbstractValidator<StudentForm>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using InternshipSystem.Api.Converters;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
public class CasUserData
|
|
||||||
{
|
|
||||||
public string AlbumNumber { get; set; }
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
|
|
||||||
[JsonConverter(typeof(StringArrayConverter<string>))]
|
|
||||||
public List<string> Mail { get; set; }
|
|
||||||
public string PersonNumber { get; set; }
|
|
||||||
|
|
||||||
[JsonConverter(typeof(StringArrayConverter<string>))]
|
|
||||||
public List<string> Pg_Cui_Portalroles { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace InternshipSystem.Api.Controllers
|
|
||||||
{
|
|
||||||
public class CasUserProfile
|
|
||||||
{
|
|
||||||
public string Service { get; set; }
|
|
||||||
public CasUserData Attributes { get; set; }
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string Client_Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
@ -10,8 +8,6 @@ namespace InternshipSystem.Api.Result
|
|||||||
public class EditionConfigurationResult
|
public class EditionConfigurationResult
|
||||||
{
|
{
|
||||||
public List<InternshipSubject> AvailableSubjects { get; set; }
|
public List<InternshipSubject> AvailableSubjects { get; set; }
|
||||||
public List<ReportField> ReportSchema { get; set; }
|
|
||||||
public Course Course { get; set; }
|
|
||||||
public DateTime EditionStart { get; set; }
|
public DateTime EditionStart { get; set; }
|
||||||
public DateTime EditionFinish { get; set; }
|
public DateTime EditionFinish { get; set; }
|
||||||
public DateTime ReportingStart { get; set; }
|
public DateTime ReportingStart { get; set; }
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Result
|
|
||||||
{
|
|
||||||
public class EditionDetailsResult
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
public DateTime EditionStart { get; set; }
|
|
||||||
public DateTime EditionFinish { get; set; }
|
|
||||||
public DateTime ReportingStart { get; set; }
|
|
||||||
public Course Course { get; set; }
|
|
||||||
public List<InternshipSubject> AvailableSubjects { get; set; }
|
|
||||||
public List<InternshipType> AvailableInternshipTypes { get; set; }
|
|
||||||
public List<ReportField> ReportSchema { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Result
|
|
||||||
{
|
|
||||||
public class EditionManagementResult
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
public DateTime EditionStart { get; set; }
|
|
||||||
public DateTime EditionFinish { get; set; }
|
|
||||||
public DateTime ReportingStart { get; set; }
|
|
||||||
public Course Course { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace InternshipSystem.Api.Result
|
namespace InternshipSystem.Api.Result
|
||||||
{
|
{
|
||||||
public class EditionResult
|
public struct EditionResult
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public DateTime EditionStart { get; set; }
|
public DateTime EditionStart { get; set; }
|
||||||
|
@ -3,6 +3,5 @@
|
|||||||
public static class Policies
|
public static class Policies
|
||||||
{
|
{
|
||||||
public const string RegisteredOnly = "RegisteredForEditionOnly";
|
public const string RegisteredOnly = "RegisteredForEditionOnly";
|
||||||
public const string IsOverseer = "IsOverseer";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,37 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Service
|
|
||||||
{
|
|
||||||
public class FileValidator
|
|
||||||
{
|
|
||||||
private readonly List<(string Mime, byte[] Signature)> validFileTypes;
|
|
||||||
|
|
||||||
public FileValidator()
|
|
||||||
{
|
|
||||||
validFileTypes = new List<(string, byte[])> {
|
|
||||||
("application/pdf", new byte[] { 0x25, 0x50, 0x44, 0x46 }),
|
|
||||||
("image/jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xDB }),
|
|
||||||
("image/jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 }),
|
|
||||||
("image/jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE1 })
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValidFile(byte[] scan)
|
|
||||||
{
|
|
||||||
return IsFileValidType(scan);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsFileValidType(byte[] scan)
|
|
||||||
{
|
|
||||||
return GetFileMime(scan) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetFileMime(byte[] scan)
|
|
||||||
{
|
|
||||||
var header = scan[..4];
|
|
||||||
|
|
||||||
return validFileTypes.FirstOrDefault(sig => sig.Signature.SequenceEqual(header)).Mime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
16
src/InternshipSystem.Api/Services/IInternshipService.cs
Normal file
16
src/InternshipSystem.Api/Services/IInternshipService.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using InternshipSystem.Api.Queries;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Services
|
||||||
|
{
|
||||||
|
public interface IInternshipService
|
||||||
|
{
|
||||||
|
Task<ActionResult> SubmitRegistration(RegistrationFormQuery registrationQuery, long personNumber,
|
||||||
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
Task<ActionResult> AddDocumentToInternship(DocumentPublishRequest documentRequest, long personNumber,
|
||||||
|
CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
114
src/InternshipSystem.Api/Services/InternshipService.cs
Normal file
114
src/InternshipSystem.Api/Services/InternshipService.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using AutoMapper;
|
||||||
|
using InternshipSystem.Api.Queries;
|
||||||
|
using InternshipSystem.Core;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Services
|
||||||
|
{
|
||||||
|
public class InternshipService : IInternshipService
|
||||||
|
{
|
||||||
|
private readonly InternshipDbContext _context;
|
||||||
|
private IMapper Mapper { get; }
|
||||||
|
|
||||||
|
public InternshipService(InternshipDbContext context, IMapper mapper)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
Mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ActionResult> SubmitRegistration(RegistrationFormQuery registrationQuery, long personNumber,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var edition = await _context.Editions.FindAsync(personNumber);
|
||||||
|
|
||||||
|
var internship = await _context.Entry(edition)
|
||||||
|
.Collection(e => e.Internships)
|
||||||
|
.Query()
|
||||||
|
.SingleAsync(i => i.Student.Id == personNumber, cancellationToken);
|
||||||
|
|
||||||
|
var internshipRegistration = internship.InternshipRegistration;
|
||||||
|
|
||||||
|
if (registrationQuery.Company != null)
|
||||||
|
{
|
||||||
|
var company = registrationQuery.Company.Id.HasValue
|
||||||
|
? await _context.Companies.SingleAsync(c => c.Id == registrationQuery.Company.Id,
|
||||||
|
cancellationToken: cancellationToken)
|
||||||
|
: Company.CreateCompany(registrationQuery.Company.Nip, registrationQuery.Company.Name);
|
||||||
|
|
||||||
|
internshipRegistration.UpdateCompany(company);
|
||||||
|
}
|
||||||
|
|
||||||
|
var officeForm = registrationQuery.BranchOffice;
|
||||||
|
if (officeForm != null)
|
||||||
|
{
|
||||||
|
BranchOffice branch;
|
||||||
|
|
||||||
|
if (officeForm.Id.HasValue)
|
||||||
|
{
|
||||||
|
branch = await _context.Entry(internshipRegistration.Company)
|
||||||
|
.Collection(c => c.Branches)
|
||||||
|
.Query()
|
||||||
|
.SingleAsync(o => o.Id == officeForm.Id, cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
branch = BranchOffice.CreateBranch(officeForm.Country, officeForm.City, officeForm.PostalCode,
|
||||||
|
officeForm.Street, officeForm.Building);
|
||||||
|
internshipRegistration.Company.AddBranchOffice(branch);
|
||||||
|
}
|
||||||
|
|
||||||
|
internshipRegistration.UpdateBranch(branch);
|
||||||
|
}
|
||||||
|
|
||||||
|
internshipRegistration.Start = registrationQuery.Start ?? internshipRegistration.Start;
|
||||||
|
internshipRegistration.End = registrationQuery.End ?? internshipRegistration.End;
|
||||||
|
|
||||||
|
if (registrationQuery.Type.HasValue && edition.IsInternshipTypeAllowed(registrationQuery.Type.Value))
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult("Edition doesn't have this type of employment in available employments type");
|
||||||
|
}
|
||||||
|
|
||||||
|
internshipRegistration.Type = registrationQuery.Type ?? internshipRegistration.Type;
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
return new OkResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ActionResult> AddDocumentToInternship(DocumentPublishRequest documentRequest, long personNumber,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var edition = await _context.Editions.FindAsync(personNumber);
|
||||||
|
|
||||||
|
var internship = await _context.Entry(edition)
|
||||||
|
.Collection(e => e.Internships)
|
||||||
|
.Query()
|
||||||
|
.SingleAsync(i => i.Student.Id == personNumber, cancellationToken);
|
||||||
|
|
||||||
|
var document = Mapper.Map<Document>(documentRequest);
|
||||||
|
|
||||||
|
if (documentRequest.Id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
internship.UpdateDocument(document);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
return new NotFoundResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
internship.AddNewDocument(document);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
return new OkResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
src/InternshipSystem.Api/Services/UserService.cs
Normal file
7
src/InternshipSystem.Api/Services/UserService.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace InternshipSystem.Api.Services
|
||||||
|
{
|
||||||
|
public class UserService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2,12 +2,12 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using InternshipSystem.Api.Controllers;
|
|
||||||
using InternshipSystem.Api.Extensions;
|
using InternshipSystem.Api.Extensions;
|
||||||
using InternshipSystem.Api.ModelBinders;
|
using InternshipSystem.Api.ModelBinders;
|
||||||
using InternshipSystem.Api.Options;
|
using InternshipSystem.Api.Options;
|
||||||
using InternshipSystem.Api.Security;
|
using InternshipSystem.Api.Security;
|
||||||
using InternshipSystem.Api.Service;
|
using InternshipSystem.Api.Services;
|
||||||
|
using InternshipSystem.Core;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@ -16,8 +16,6 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Converters;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api
|
namespace InternshipSystem.Api
|
||||||
{
|
{
|
||||||
@ -28,30 +26,10 @@ namespace InternshipSystem.Api
|
|||||||
public Startup(IConfiguration configuration) =>
|
public Startup(IConfiguration configuration) =>
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services) =>
|
||||||
{
|
|
||||||
services
|
|
||||||
.Configure<SecurityOptions>(Configuration.GetSection("SecurityOptions"));
|
|
||||||
|
|
||||||
services
|
|
||||||
.AddStudentAuthentication()
|
|
||||||
.AddAuthorization(o =>
|
|
||||||
{
|
|
||||||
o.AddPolicy(Policies.RegisteredOnly, policy => policy.RequireClaim("Edition"));
|
|
||||||
//TODO: change to claim for InternshipRepresentative
|
|
||||||
o.AddPolicy(Policies.IsOverseer, policy => policy.RequireClaim("PersonNumber"));
|
|
||||||
})
|
|
||||||
.AddHttpClient<GutCasClient>();
|
|
||||||
|
|
||||||
services
|
|
||||||
.AddDbContext<InternshipDbContext>(o =>
|
|
||||||
o.UseNpgsql(Configuration.GetConnectionString("InternshipDatabase")))
|
|
||||||
.AddScoped<DatabaseFiller>()
|
|
||||||
.AddScoped<FileValidator>()
|
|
||||||
.AddScoped<JwtTokenService>()
|
|
||||||
.AddAutoMapper(cfg => cfg.AddProfile<ApiProfile>());
|
|
||||||
|
|
||||||
services
|
services
|
||||||
|
.Configure<SecurityOptions>(Configuration.GetSection("SecurityOptions"))
|
||||||
|
.AddDbContext<InternshipDbContext>(o => o.UseNpgsql(Configuration.GetConnectionString("InternshipDatabase")))
|
||||||
.AddSwaggerGen(options =>
|
.AddSwaggerGen(options =>
|
||||||
{
|
{
|
||||||
options.SwaggerDoc("v1", new OpenApiInfo {Title = "InternshipSystem Api - TEST", Version = "v1"});
|
options.SwaggerDoc("v1", new OpenApiInfo {Title = "InternshipSystem Api - TEST", Version = "v1"});
|
||||||
@ -59,24 +37,26 @@ namespace InternshipSystem.Api
|
|||||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
options.IncludeXmlComments(xmlPath);
|
options.IncludeXmlComments(xmlPath);
|
||||||
})
|
})
|
||||||
.AddSwaggerGenNewtonsoftSupport()
|
.AddScoped<DatabaseFiller>()
|
||||||
.AddControllers(o => { o.ModelBinderProviders.Insert(0, new UserBinderProvider()); })
|
.AddScoped<IInternshipService, InternshipService>()
|
||||||
.AddNewtonsoftJson(options =>
|
.AddScoped<JwtTokenService>()
|
||||||
|
.AddAutoMapper(cfg => cfg.AddProfile<ApiProfile>())
|
||||||
|
.AddStudentAuthentication()
|
||||||
|
.AddAuthorization(o =>
|
||||||
{
|
{
|
||||||
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
o.AddPolicy(Policies.RegisteredOnly, policy => policy.RequireClaim("Edition"));
|
||||||
options.SerializerSettings.Converters.Add(new StringEnumConverter());
|
})
|
||||||
});
|
.AddControllers(o =>
|
||||||
}
|
{
|
||||||
|
o.ModelBinderProviders.Insert(0, new UserBinderProvider());
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
app.UseMigration();
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app
|
app.UseDeveloperExceptionPage();
|
||||||
.UseDefaultData("true".Equals(Environment.GetEnvironmentVariable("FILLER__USE_DEFAULT_DATA")))
|
|
||||||
.UseDeveloperExceptionPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app
|
app
|
||||||
|
@ -1,189 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using IdentityServer4.Extensions;
|
|
||||||
using InternshipSystem.Api.Commands;
|
|
||||||
using InternshipSystem.Api.Security;
|
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
|
||||||
using InternshipSystem.Core.ValueObject;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.UseCases
|
|
||||||
{
|
|
||||||
public class UpdateInternshipRegistrationUseCase
|
|
||||||
{
|
|
||||||
private readonly InternshipDbContext _dbContext;
|
|
||||||
private readonly Internship _internship;
|
|
||||||
private readonly Edition _edition;
|
|
||||||
private readonly User _user;
|
|
||||||
private readonly InternshipRegistration subjectRegistration;
|
|
||||||
|
|
||||||
public UpdateInternshipRegistrationUseCase(InternshipDbContext dbContext,
|
|
||||||
Internship internship, Edition edition, User user)
|
|
||||||
{
|
|
||||||
_dbContext = dbContext;
|
|
||||||
_internship = internship;
|
|
||||||
_edition = edition;
|
|
||||||
_user = user;
|
|
||||||
_internship = internship;
|
|
||||||
subjectRegistration = internship.InternshipRegistration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(DocumentState State, IEnumerable<ErrorDescription>)> UpdateInternshipRegistration(
|
|
||||||
UpdateRegistrationForm registrationCommand,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
UpdateTimeFrame(registrationCommand);
|
|
||||||
subjectRegistration.DeclaredHours = registrationCommand.Hours ?? subjectRegistration.DeclaredHours;
|
|
||||||
|
|
||||||
if (registrationCommand.Type.HasValue)
|
|
||||||
{
|
|
||||||
UpdateInternshipType(registrationCommand.Type.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (registrationCommand.Mentor.HasValue)
|
|
||||||
{
|
|
||||||
UpdateMentor(registrationCommand.Mentor.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!registrationCommand.Subjects.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
UpdateSubjects(registrationCommand.Subjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (registrationCommand.Company.HasValue)
|
|
||||||
{
|
|
||||||
await UpdateCompanyAndBranch(registrationCommand.Company.Value, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
return subjectRegistration.ValidateStatus(_edition);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateTimeFrame(UpdateRegistrationForm registrationCommand)
|
|
||||||
{
|
|
||||||
subjectRegistration.Start = registrationCommand.Start ?? subjectRegistration.Start;
|
|
||||||
subjectRegistration.End = registrationCommand.End ?? subjectRegistration.End;
|
|
||||||
|
|
||||||
if (!_edition.IsDateDuringEdition(subjectRegistration.Start, subjectRegistration.End))
|
|
||||||
{
|
|
||||||
_internship.AddNewDocument("", DocumentType.OutsideTermApproval);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_internship.RemoveDocument(DocumentType.OutsideTermApproval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateInternshipType(long typeId)
|
|
||||||
{
|
|
||||||
var editionInternshipType = _edition.AvailableInternshipTypes.FirstOrDefault(i => i.InternshipTypeId == typeId);
|
|
||||||
|
|
||||||
if (editionInternshipType?.InternshipType.RequireDeansApproval == true)
|
|
||||||
{
|
|
||||||
_internship.AddNewDocument("", DocumentType.InternshipTypeApproval);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_internship.RemoveDocument(DocumentType.InternshipTypeApproval);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editionInternshipType?.InternshipType.RequireInsurance == true)
|
|
||||||
{
|
|
||||||
_internship.AddNewDocument("", DocumentType.NnwInsurance);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_internship.RemoveDocument(DocumentType.NnwInsurance);
|
|
||||||
}
|
|
||||||
|
|
||||||
subjectRegistration.Type = editionInternshipType?.InternshipType ?? subjectRegistration.Type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task UpdateCompanyAndBranch(UpdateCompany companyUpdate, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var company = subjectRegistration.Company;
|
|
||||||
|
|
||||||
if (companyUpdate.Id.HasValue)
|
|
||||||
{
|
|
||||||
company = await _dbContext.Companies
|
|
||||||
.Include(c => c.Branches)
|
|
||||||
.FirstAsync(c => c.Id == companyUpdate.Id.Value, cancellationToken);
|
|
||||||
}
|
|
||||||
else if (companyUpdate.IsCustomUpdate)
|
|
||||||
{
|
|
||||||
company = await _dbContext.Companies
|
|
||||||
.Include(c => c.Branches)
|
|
||||||
.SingleOrDefaultAsync(c => c.Provider == _user.PersonNumber, cancellationToken)
|
|
||||||
?? Company.CreateCompany(companyUpdate.Nip, companyUpdate.Name, _user.PersonNumber);
|
|
||||||
|
|
||||||
company.Name = companyUpdate.Name ?? company.Name;
|
|
||||||
company.Nip = companyUpdate.Nip ?? company.Nip;
|
|
||||||
|
|
||||||
subjectRegistration.BranchAddress = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (companyUpdate.BranchOffice.HasValue)
|
|
||||||
{
|
|
||||||
var branchUpdate = companyUpdate.BranchOffice.Value;
|
|
||||||
|
|
||||||
var branch = subjectRegistration.BranchAddress;
|
|
||||||
|
|
||||||
if (branchUpdate.Id.HasValue)
|
|
||||||
{
|
|
||||||
branch = company.Branches.First(b => b.Id == branchUpdate.Id.Value);
|
|
||||||
}
|
|
||||||
else if (branchUpdate.IsCustomUpdate)
|
|
||||||
{
|
|
||||||
branch = company.Branches.FirstOrDefault(b => b.Provider == _user.PersonNumber);
|
|
||||||
|
|
||||||
if (branch == null)
|
|
||||||
{
|
|
||||||
branch = BranchOffice.CreateBranch(branchUpdate.Country, branchUpdate.City, branchUpdate.PostalCode,
|
|
||||||
branchUpdate.Street, branchUpdate.Building, _user.PersonNumber);
|
|
||||||
company.AddBranchOffice(branch);
|
|
||||||
}
|
|
||||||
|
|
||||||
branch.Address.Country = branchUpdate.Country ?? branch.Address.Country;
|
|
||||||
branch.Address.City = branchUpdate.City ?? branch.Address.City;
|
|
||||||
branch.Address.PostalCode = branchUpdate.PostalCode ?? branch.Address.PostalCode;
|
|
||||||
branch.Address.Street = branchUpdate.Country ?? branch.Address.Street;
|
|
||||||
branch.Address.Building = branchUpdate.Building ?? branch.Address.Building;
|
|
||||||
}
|
|
||||||
|
|
||||||
subjectRegistration.BranchAddress = branch;
|
|
||||||
}
|
|
||||||
|
|
||||||
subjectRegistration.Company = company;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateSubjects(IEnumerable<long> subjects)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!_edition.AreSubjectsAvailable(subjects))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("subjects chosen are not available in this edition");
|
|
||||||
}
|
|
||||||
|
|
||||||
subjectRegistration.Subjects =
|
|
||||||
subjects
|
|
||||||
.Select(i => new ProgramSubject
|
|
||||||
{
|
|
||||||
Registration = subjectRegistration,
|
|
||||||
InternshipSubjectId = i
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateMentor(UpdateMentor mentorUpdate)
|
|
||||||
{
|
|
||||||
subjectRegistration.Mentor ??= new Mentor();
|
|
||||||
|
|
||||||
subjectRegistration.Mentor.UpdateInformation(mentorUpdate.FirstName, mentorUpdate.LastName, mentorUpdate.Email, mentorUpdate.PhoneNumber);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +1,20 @@
|
|||||||
using FluentValidation;
|
namespace InternshipSystem.Core
|
||||||
using FluentValidation.Validators;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core
|
|
||||||
{
|
{
|
||||||
public class BranchOffice
|
public class BranchOffice
|
||||||
{
|
{
|
||||||
public BranchOffice()
|
public BranchOffice()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
private BranchOffice(BranchAddress address)
|
||||||
private BranchOffice(BranchAddress address, long provider)
|
|
||||||
{
|
{
|
||||||
Address = address;
|
Address = address;
|
||||||
Provider = provider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public BranchAddress Address { get; set; }
|
public BranchAddress Address { get; set; }
|
||||||
|
|
||||||
public long Provider { get; set; }
|
public static BranchOffice CreateBranch(string country, string city, string postalCode, string street, string building)
|
||||||
|
|
||||||
public static BranchOffice CreateBranch(string country, string city, string postalCode, string street,
|
|
||||||
string building, long provider = 0)
|
|
||||||
{
|
{
|
||||||
var address = new BranchAddress
|
var address = new BranchAddress
|
||||||
{
|
{
|
||||||
@ -33,16 +25,7 @@ namespace InternshipSystem.Core
|
|||||||
PostalCode = postalCode
|
PostalCode = postalCode
|
||||||
};
|
};
|
||||||
|
|
||||||
return new BranchOffice(address, provider);
|
return new BranchOffice(address);
|
||||||
}
|
|
||||||
|
|
||||||
public class Validator : AbstractValidator<BranchOffice>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(x => x.Address)
|
|
||||||
.SetValidator(new BranchAddress.Validator());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,44 +1,29 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
|
||||||
using FluentValidation.Validators;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core
|
namespace InternshipSystem.Core
|
||||||
{
|
{
|
||||||
public class Company
|
public class Company
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public string Nip { get; set; }
|
public Nip Nip { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public List<BranchOffice> Branches { get; set; }
|
public List<BranchOffice> Branches { get; set; }
|
||||||
|
|
||||||
public long Provider { get; set; }
|
public static Company CreateCompany(string nip, string name) =>
|
||||||
|
|
||||||
public static Company CreateCompany(string nip, string name, long provider = 0) =>
|
|
||||||
new Company
|
new Company
|
||||||
{
|
{
|
||||||
Nip = nip,
|
Nip = nip,
|
||||||
Name = name,
|
Name = name
|
||||||
Provider = provider,
|
|
||||||
Branches = new List<BranchOffice>()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public void AddBranchAddress(BranchAddress branch)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void AddBranchOffice(BranchOffice createBranch)
|
public void AddBranchOffice(BranchOffice createBranch)
|
||||||
{
|
{
|
||||||
Branches.Add(createBranch);
|
Branches.Add(createBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Validator : AbstractValidator<Company>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(x => x.Nip)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.company.nip.empty");
|
|
||||||
RuleFor(x => x.Name)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.company.name.empty");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,24 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
namespace InternshipSystem.Core
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Entity
|
|
||||||
{
|
{
|
||||||
public class Course
|
public class Course
|
||||||
{
|
{
|
||||||
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; }
|
|
||||||
|
|
||||||
public static Course CreateCourse(string name, string nameEng) =>
|
|
||||||
new Course
|
|
||||||
{
|
|
||||||
Name = name,
|
|
||||||
NameEng = nameEng,
|
|
||||||
};
|
|
||||||
|
|
||||||
public void UpdateCourse(string name, string nameEng)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
NameEng = nameEng;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,19 +6,9 @@ namespace InternshipSystem.Core
|
|||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public DocumentScan Scan { get; set; }
|
public byte[] Scan { get; set; }
|
||||||
public DocumentType Type { get; set; }
|
public DocumentType Type { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
public string ChangeStateComment { get; set; }
|
public string RejectionReason { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public class DocumentScan
|
|
||||||
{
|
|
||||||
public long DocumentId { get; set; }
|
|
||||||
public Document Document { get; set; }
|
|
||||||
public long Size { get; set; }
|
|
||||||
public string Filename { get; set; }
|
|
||||||
public string Mime { get; set; }
|
|
||||||
public byte[] File { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
@ -17,128 +16,29 @@ namespace InternshipSystem.Core
|
|||||||
public List<Internship> Internships { get; set; }
|
public List<Internship> Internships { get; set; }
|
||||||
public List<EditionSubject> AvailableSubjects { get; set; }
|
public List<EditionSubject> AvailableSubjects { get; set; }
|
||||||
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
|
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
|
||||||
public List<ReportFieldEdition> ReportSchema { get; set; }
|
|
||||||
|
|
||||||
public bool IsOpen => EditionFinish < DateTime.Today;
|
public bool IsOpen => EditionFinish < DateTime.Today;
|
||||||
|
|
||||||
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course,
|
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
|
||||||
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
|
|
||||||
{
|
|
||||||
var newEdition = CreateEdition(start, end, reportingStart, course);
|
|
||||||
|
|
||||||
newEdition.AvailableSubjects =
|
|
||||||
subjectsIds
|
|
||||||
.Select(s => new EditionSubject
|
|
||||||
{
|
|
||||||
Edition = newEdition,
|
|
||||||
InternshipSubjectId = s,
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
newEdition.AvailableInternshipTypes =
|
|
||||||
internshipTypesIds
|
|
||||||
.Select(i => new EditionInternshipType
|
|
||||||
{
|
|
||||||
Edition = newEdition,
|
|
||||||
InternshipTypeId = i,
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
newEdition.ReportSchema =
|
|
||||||
reportFieldIds
|
|
||||||
.Select(i => new ReportFieldEdition
|
|
||||||
{
|
|
||||||
Edition = newEdition,
|
|
||||||
ReportFieldId = i,
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
return newEdition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course)
|
|
||||||
{
|
{
|
||||||
return new Edition
|
return new Edition
|
||||||
{
|
{
|
||||||
EditionStart = start,
|
EditionStart = start,
|
||||||
EditionFinish = end,
|
EditionFinish = end,
|
||||||
ReportingStart = reportingStart,
|
ReportingStart = reportingStart
|
||||||
Course = course,
|
|
||||||
AvailableSubjects = new List<EditionSubject>(),
|
|
||||||
AvailableInternshipTypes = new List<EditionInternshipType>(),
|
|
||||||
ReportSchema = new List<ReportFieldEdition>()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateEdition(DateTime? start, DateTime? end, DateTime? reportingStart, Course course,
|
public bool IsInternshipTypeAllowed(InternshipType registrationQueryType)
|
||||||
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
|
|
||||||
{
|
{
|
||||||
EditionStart = start ?? EditionStart;
|
return AvailableInternshipTypes.Select(it => it.InternshipType).Contains(registrationQueryType);
|
||||||
EditionFinish = end ?? EditionFinish;
|
|
||||||
ReportingStart = reportingStart ?? ReportingStart;
|
|
||||||
Course = course;
|
|
||||||
|
|
||||||
if (subjectsIds != null)
|
|
||||||
{
|
|
||||||
AvailableSubjects =
|
|
||||||
subjectsIds
|
|
||||||
.Select(s => new EditionSubject
|
|
||||||
{
|
|
||||||
InternshipSubjectId = s,
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internshipTypesIds != null)
|
|
||||||
{
|
|
||||||
AvailableInternshipTypes =
|
|
||||||
internshipTypesIds
|
|
||||||
.Select(i => new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipTypeId = i,
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reportFieldIds != null)
|
|
||||||
{
|
|
||||||
ReportSchema =
|
|
||||||
reportFieldIds
|
|
||||||
.Select(i => new ReportFieldEdition
|
|
||||||
{
|
|
||||||
ReportFieldId = i,
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterInternship(Student student)
|
public void RegisterInternship(Student student)
|
||||||
{
|
{
|
||||||
if (Internships.Any(i => i.Student.Id == student.Id))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("error.registration.already_registered");
|
|
||||||
}
|
|
||||||
|
|
||||||
var internship = Internship.CreateStudentsInternship(student);
|
var internship = Internship.CreateStudentsInternship(student);
|
||||||
|
|
||||||
Internships.Add(internship);
|
Internships.Add(internship);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDateDuringEdition(DateTime start, DateTime end)
|
|
||||||
{
|
|
||||||
return start >= EditionStart && end <= EditionFinish;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsTypeAvailable(InternshipType internshipType)
|
|
||||||
{
|
|
||||||
return AvailableInternshipTypes.Any(e => e.InternshipType == internshipType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AreSubjectsAvailable(IEnumerable<long> internshipSubjects)
|
|
||||||
{
|
|
||||||
return internshipSubjects.All(s => AvailableSubjects.Any(su => su.InternshipSubjectId == s));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValidDates => EditionStart <= EditionFinish;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using FluentValidation.Results;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core
|
|
||||||
{
|
|
||||||
static internal class Extensions
|
|
||||||
{
|
|
||||||
public static IEnumerable<ErrorDescription> ToErrorDescription(this ValidationResult result)
|
|
||||||
{
|
|
||||||
return result.Errors.Select(failure => new ErrorDescription { Key = failure.ErrorCode, Parameters = failure.FormattedMessagePlaceholderValues });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +1,37 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
|
||||||
using InternshipSystem.Core.ValueObject;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Entity.Internship
|
namespace InternshipSystem.Core
|
||||||
{
|
{
|
||||||
public class Internship
|
public class Internship
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public Student Student { get; set; }
|
public Student Student { get; set; }
|
||||||
public InternshipRegistration InternshipRegistration { get; set; }
|
public InternshipRegistration InternshipRegistration { get; set; }
|
||||||
|
public InternshipProgram InternshipProgram { get; set; }
|
||||||
public Report Report { get; set; }
|
public Report Report { get; set; }
|
||||||
|
public List<Document> Approvals { get; set; }
|
||||||
public List<Document> Documentation { get; set; }
|
public List<Document> Documentation { get; set; }
|
||||||
|
public float? Grade { get; set; }
|
||||||
|
|
||||||
public Edition Edition { get; set; }
|
public Edition Edition { get; set; }
|
||||||
|
|
||||||
public float? Grade { get; set; }
|
public void UpdateDocument(Document document)
|
||||||
|
{
|
||||||
|
var oldDocument = Documentation.First(d => d.Id == document.Id);
|
||||||
|
|
||||||
|
oldDocument.Description = document.Description ?? oldDocument.Description;
|
||||||
|
oldDocument.Scan = document.Scan ?? oldDocument.Scan;
|
||||||
|
oldDocument.Type = document.Type;
|
||||||
|
oldDocument.State = DocumentState.Submitted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddNewDocument(Document document)
|
||||||
|
{
|
||||||
|
document.State = DocumentState.Submitted;
|
||||||
|
|
||||||
|
Documentation.Add(document);
|
||||||
|
}
|
||||||
|
|
||||||
public static Internship CreateStudentsInternship(Student student)
|
public static Internship CreateStudentsInternship(Student student)
|
||||||
{
|
{
|
||||||
@ -24,82 +40,12 @@ namespace InternshipSystem.Core.Entity.Internship
|
|||||||
internship.Student = student;
|
internship.Student = student;
|
||||||
|
|
||||||
internship.InternshipRegistration = InternshipRegistration.Create();
|
internship.InternshipRegistration = InternshipRegistration.Create();
|
||||||
|
internship.InternshipProgram = InternshipProgram.Create();
|
||||||
internship.Report = Report.Create();
|
internship.Report = Report.Create();
|
||||||
|
internship.Approvals = new List<Document>();
|
||||||
internship.Documentation = new List<Document>();
|
internship.Documentation = new List<Document>();
|
||||||
|
|
||||||
if (student.Semester != 6)
|
|
||||||
{
|
|
||||||
internship.AddNewDocument("", DocumentType.OutsideSemesterApproval);
|
|
||||||
}
|
|
||||||
|
|
||||||
return internship;
|
return internship;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddNewDocument(string description, DocumentType type)
|
|
||||||
{
|
|
||||||
if (type != DocumentType.Other && Documentation.Any(d => d.Type == type))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var document = new Document
|
|
||||||
{
|
|
||||||
Description = description,
|
|
||||||
Type = type,
|
|
||||||
State = DocumentState.Draft
|
|
||||||
};
|
|
||||||
|
|
||||||
Documentation.Add(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveDocument(DocumentType documentType)
|
|
||||||
{
|
|
||||||
if (documentType == DocumentType.Other)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var doc = Documentation.FirstOrDefault(d => d.Type == documentType);
|
|
||||||
|
|
||||||
if (doc != null)
|
|
||||||
{
|
|
||||||
Documentation.Remove(doc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveDocument(long id)
|
|
||||||
{
|
|
||||||
var doc = Documentation.FirstOrDefault(d => d.Id == id);
|
|
||||||
|
|
||||||
if (doc != null)
|
|
||||||
{
|
|
||||||
Documentation.Remove(doc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<ErrorDescription> ValidateStatus()
|
|
||||||
{
|
|
||||||
var validator = new Validator();
|
|
||||||
|
|
||||||
var result = validator.Validate(this);
|
|
||||||
|
|
||||||
return result.ToErrorDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Validator : AbstractValidator<Internship>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(i => i.Report)
|
|
||||||
.Must(r => r.State == DocumentState.Accepted)
|
|
||||||
.WithMessage("error.report.not_accepted");
|
|
||||||
RuleFor(i => i.InternshipRegistration)
|
|
||||||
.Must(r => r.State == DocumentState.Accepted)
|
|
||||||
.WithMessage("error.registration.not_accepted");
|
|
||||||
RuleForEach(i => i.Documentation)
|
|
||||||
.Must(d => d.State == DocumentState.Accepted)
|
|
||||||
.WithMessage("error.documentation.not_accepted");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Core
|
||||||
|
{
|
||||||
|
public class InternshipProgram
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public Mentor Mentor { get; set; }
|
||||||
|
public DocumentState State { get; set; }
|
||||||
|
public List<ProgramSubject> ChosenSubjects { get; set; }
|
||||||
|
|
||||||
|
public static InternshipProgram Create()
|
||||||
|
{
|
||||||
|
return new InternshipProgram();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,82 +1,31 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using System.Linq;
|
|
||||||
using FluentValidation;
|
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Entity.Internship
|
namespace InternshipSystem.Core
|
||||||
{
|
{
|
||||||
public class InternshipRegistration
|
public class InternshipRegistration
|
||||||
{
|
{
|
||||||
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 List<ProgramSubject> Subjects { get; set; }
|
|
||||||
public InternshipType Type { get; set; }
|
public InternshipType Type { 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()
|
||||||
{
|
{
|
||||||
return new InternshipRegistration();
|
return new InternshipRegistration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateCompany(Company newCompany)
|
||||||
public (DocumentState State, IEnumerable<ErrorDescription>) ValidateStatus(Edition edition)
|
|
||||||
{
|
{
|
||||||
var validator = new Validator(edition);
|
Company = newCompany;
|
||||||
|
|
||||||
var result = validator.Validate(this);
|
|
||||||
|
|
||||||
State = result.IsValid ? DocumentState.Submitted : DocumentState.Draft;
|
|
||||||
|
|
||||||
SubmissionDate = DocumentState.Submitted.Equals(State) ? DateTime.UtcNow.AddHours(1) : SubmissionDate;
|
|
||||||
|
|
||||||
return (State, result.ToErrorDescription());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Validator : AbstractValidator<InternshipRegistration>
|
public void UpdateBranch(BranchOffice branch)
|
||||||
{
|
{
|
||||||
public Validator(Edition edition)
|
BranchAddress = branch;
|
||||||
{
|
|
||||||
RuleFor(x => x.Company)
|
|
||||||
.SetValidator(new Company.Validator())
|
|
||||||
.NotNull();
|
|
||||||
RuleFor(x => x.BranchAddress)
|
|
||||||
.SetValidator(new BranchOffice.Validator())
|
|
||||||
.NotNull();
|
|
||||||
RuleFor(x => x.Mentor)
|
|
||||||
.SetValidator(new Mentor.Validate())
|
|
||||||
.NotNull();
|
|
||||||
RuleFor(x => x.Subjects)
|
|
||||||
.NotEmpty()
|
|
||||||
.Must(s => edition.AreSubjectsAvailable(s.Select(su => su.InternshipSubjectId)))
|
|
||||||
.WithMessage("error.subjects.not_available");
|
|
||||||
RuleFor(x => x.Type)
|
|
||||||
.NotNull()
|
|
||||||
.Must(edition.IsTypeAvailable)
|
|
||||||
.WithMessage("error.type.not_available");
|
|
||||||
RuleFor(x => x.Start)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.start_date.empty");
|
|
||||||
RuleFor(x => x.End)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.end_date.empty");
|
|
||||||
RuleFor(x => x.DeclaredHours)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.declared_hours.empty");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ErrorDescription
|
|
||||||
{
|
|
||||||
public string Key { get; set; }
|
|
||||||
public Dictionary<string, object> Parameters { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,6 +5,5 @@
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string DescriptionEng { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,14 @@
|
|||||||
namespace InternshipSystem.Core.Entity.Internship
|
namespace InternshipSystem.Core.Entity.Internship
|
||||||
{
|
{
|
||||||
public class InternshipType
|
public enum InternshipType
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
FreeInternship = 0,
|
||||||
public string Label { get; set; }
|
GraduateInternship = 1,
|
||||||
public string LabelEng { get; set; }
|
FreeApprenticeship = 2,
|
||||||
public string Description { get; set; }
|
PaidApprenticeship = 3,
|
||||||
public string DescriptionEng { get; set; }
|
ForeignInternship = 4,
|
||||||
public bool RequireDeansApproval { get; set; }
|
UOP = 5,
|
||||||
public bool RequireInsurance { get; set; }
|
UD = 6,
|
||||||
|
UZ = 7,
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,17 +6,12 @@ namespace InternshipSystem.Core
|
|||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
public string Value { get; set; }
|
public RangeOfActivity Range { get; set; }
|
||||||
|
public Uri SiteAddress { get; set; }
|
||||||
|
|
||||||
public static Report Create()
|
public static Report Create()
|
||||||
{
|
{
|
||||||
return new Report();
|
return new Report();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateReport(string reportValue)
|
|
||||||
{
|
|
||||||
Value = reportValue;
|
|
||||||
State = DocumentState.Submitted;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Entity
|
|
||||||
{
|
|
||||||
public class ReportField
|
|
||||||
{
|
|
||||||
public ReportField()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReportField(string label, string labelEng, string description, string descriptionEng, FieldType fieldType)
|
|
||||||
{
|
|
||||||
Label = label;
|
|
||||||
LabelEng = labelEng;
|
|
||||||
Description = description;
|
|
||||||
DescriptionEng = descriptionEng;
|
|
||||||
FieldType = fieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long Id { get; set; }
|
|
||||||
public string Label { get; set; }
|
|
||||||
public string LabelEng { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public string DescriptionEng { get; set; }
|
|
||||||
public FieldType FieldType { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum FieldType
|
|
||||||
{
|
|
||||||
LongText,
|
|
||||||
ShortText,
|
|
||||||
Select,
|
|
||||||
Radial,
|
|
||||||
Checkbox
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ReportChoiceField : ReportField
|
|
||||||
{
|
|
||||||
public ReportChoiceField(string label, string labelEng, string description, string descriptionEng,
|
|
||||||
FieldType fieldType, string[] choices) : base(label, labelEng, description, descriptionEng, fieldType)
|
|
||||||
{
|
|
||||||
Choices = choices;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] Choices { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace InternshipSystem.Core
|
|
||||||
{
|
|
||||||
public class StaticPage
|
|
||||||
{
|
|
||||||
public long Id { get; set; }
|
|
||||||
public string AccessName { get; set; }
|
|
||||||
public string Title { get; set; }
|
|
||||||
public string TitleEng { get; set; }
|
|
||||||
public string Content { get; set; }
|
|
||||||
public string ContentEng { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,19 +9,6 @@ namespace InternshipSystem.Core
|
|||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string Course { get; set; }
|
public int Semester { get; set; }
|
||||||
public int? Semester { get; set; }
|
|
||||||
|
|
||||||
public static Student CreateStudent(long id, string firstName, string lastName, string email, in int albumNumber)
|
|
||||||
{
|
|
||||||
return new Student
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
AlbumNumber = albumNumber,
|
|
||||||
FirstName = firstName,
|
|
||||||
LastName = lastName,
|
|
||||||
Email = email
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,8 +5,4 @@
|
|||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="FluentValidation" Version="9.1.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -5,12 +5,7 @@ namespace InternshipSystem.Core.UglyOrmArtifacts
|
|||||||
{
|
{
|
||||||
public class EditionInternshipType
|
public class EditionInternshipType
|
||||||
{
|
{
|
||||||
public Edition Edition { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public Guid EditionId { get; set; }
|
|
||||||
|
|
||||||
public InternshipType InternshipType { get; set; }
|
public InternshipType InternshipType { get; set; }
|
||||||
|
|
||||||
public long InternshipTypeId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,8 +4,8 @@ namespace InternshipSystem.Core.UglyOrmArtifacts
|
|||||||
{
|
{
|
||||||
public class ProgramSubject
|
public class ProgramSubject
|
||||||
{
|
{
|
||||||
public long InternshipRegistrationId { get; set; }
|
public long InternshipProgramId { get; set; }
|
||||||
public InternshipRegistration Registration { get; set; }
|
public InternshipProgram Program { get; set; }
|
||||||
public long InternshipSubjectId { get; set; }
|
public long InternshipSubjectId { get; set; }
|
||||||
public InternshipSubject Subject { get; set; }
|
public InternshipSubject Subject { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core.UglyOrmArtifacts
|
|
||||||
{
|
|
||||||
public class ReportFieldEdition
|
|
||||||
{
|
|
||||||
public Guid EditionId { get; set; }
|
|
||||||
public Edition Edition { get; set; }
|
|
||||||
public long ReportFieldId { get; set; }
|
|
||||||
public ReportField Field { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,4 @@
|
|||||||
using FluentValidation;
|
namespace InternshipSystem.Core
|
||||||
using FluentValidation.Validators;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core
|
|
||||||
{
|
{
|
||||||
public class BranchAddress
|
public class BranchAddress
|
||||||
{
|
{
|
||||||
@ -10,27 +7,5 @@ namespace InternshipSystem.Core
|
|||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
public string PostalCode { get; set; }
|
public string PostalCode { get; set; }
|
||||||
public string Country { get; set; }
|
public string Country { get; set; }
|
||||||
|
|
||||||
public class Validator : AbstractValidator<BranchAddress>
|
|
||||||
{
|
|
||||||
public Validator()
|
|
||||||
{
|
|
||||||
RuleFor(x => x.Country)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.branch.country.empty");
|
|
||||||
RuleFor(x => x.City)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.branch.city.empty");
|
|
||||||
RuleFor(x => x.PostalCode)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.branch.postal_code.empty");
|
|
||||||
RuleFor(x => x.Street)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.branch.street.empty");
|
|
||||||
RuleFor(x => x.Building)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.branch.building.empty");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,15 +2,9 @@
|
|||||||
{
|
{
|
||||||
public enum DocumentState
|
public enum DocumentState
|
||||||
{
|
{
|
||||||
// Oczekujaca
|
NotSubmitted,
|
||||||
Draft,
|
|
||||||
// Oczekuje na akceptacje
|
|
||||||
Submitted,
|
Submitted,
|
||||||
// Zaakceptowana
|
|
||||||
Accepted,
|
Accepted,
|
||||||
// Odrzucona
|
Rejected
|
||||||
Rejected,
|
|
||||||
// Archiwalna
|
|
||||||
Archival
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,12 +2,6 @@
|
|||||||
{
|
{
|
||||||
public enum DocumentType
|
public enum DocumentType
|
||||||
{
|
{
|
||||||
IppScan,
|
IPPScan
|
||||||
OutsideTermApproval,
|
|
||||||
InternshipTypeApproval,
|
|
||||||
OutsideSemesterApproval,
|
|
||||||
NnwInsurance,
|
|
||||||
InternshipEvaluation,
|
|
||||||
Other
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,40 +1,10 @@
|
|||||||
using FluentValidation;
|
namespace InternshipSystem.Core
|
||||||
|
|
||||||
namespace InternshipSystem.Core
|
|
||||||
{
|
{
|
||||||
public class Mentor
|
public class Mentor
|
||||||
{
|
{
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string PhoneNumber { get; set; }
|
public PhoneNumber PhoneNumber { get; set; }
|
||||||
|
|
||||||
public void UpdateInformation(string firstName, string lastName, string email, string phoneNumber)
|
|
||||||
{
|
|
||||||
FirstName = firstName ?? FirstName;
|
|
||||||
LastName = lastName ?? LastName;
|
|
||||||
Email = email ?? Email;
|
|
||||||
PhoneNumber = phoneNumber ?? PhoneNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Validate : AbstractValidator<Mentor>
|
|
||||||
{
|
|
||||||
public Validate()
|
|
||||||
{
|
|
||||||
RuleFor(x => x.FirstName)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.mentor.first_name.empty");
|
|
||||||
RuleFor(x => x.LastName)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.mentor.last_name.empty");
|
|
||||||
RuleFor(x => x.Email)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.mentor.email.empty");
|
|
||||||
RuleFor(x => x.PhoneNumber)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("error.mentor.phone_number.empty");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
18
src/InternshipSystem.Core/ValueObject/Nip.cs
Normal file
18
src/InternshipSystem.Core/ValueObject/Nip.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace InternshipSystem.Core
|
||||||
|
{
|
||||||
|
public struct Nip
|
||||||
|
{
|
||||||
|
private readonly string _nip;
|
||||||
|
|
||||||
|
public Nip(string nip)
|
||||||
|
{
|
||||||
|
_nip = nip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(Nip nip) =>
|
||||||
|
nip._nip;
|
||||||
|
|
||||||
|
public static implicit operator Nip(string maybeNip) =>
|
||||||
|
new Nip(maybeNip);
|
||||||
|
}
|
||||||
|
}
|
18
src/InternshipSystem.Core/ValueObject/PhoneNumber.cs
Normal file
18
src/InternshipSystem.Core/ValueObject/PhoneNumber.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace InternshipSystem.Core
|
||||||
|
{
|
||||||
|
public struct PhoneNumber
|
||||||
|
{
|
||||||
|
private readonly string _phoneNumber;
|
||||||
|
|
||||||
|
public PhoneNumber(string phoneNumber)
|
||||||
|
{
|
||||||
|
_phoneNumber = phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(PhoneNumber number) =>
|
||||||
|
number._phoneNumber;
|
||||||
|
|
||||||
|
public static implicit operator PhoneNumber(string maybeNumber) =>
|
||||||
|
new PhoneNumber(maybeNumber);
|
||||||
|
}
|
||||||
|
}
|
@ -3,30 +3,20 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Core;
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
using InternshipSystem.Core.ValueObject;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace InternshipSystem.Repository
|
namespace InternshipSystem.Repository
|
||||||
{
|
{
|
||||||
public class DatabaseFiller
|
public class DatabaseFiller
|
||||||
{
|
{
|
||||||
private InternshipDbContext Context { get; }
|
|
||||||
|
|
||||||
public DatabaseFiller(InternshipDbContext context)
|
public DatabaseFiller(InternshipDbContext context)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FillAll()
|
public InternshipDbContext Context { get; }
|
||||||
{
|
|
||||||
await FillCompanies();
|
|
||||||
await FillInternshipTypes();
|
|
||||||
await FillEditions();
|
|
||||||
await FillStaticPages();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task FillCompanies()
|
public async Task FillCompanies()
|
||||||
{
|
{
|
||||||
@ -34,6 +24,7 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
new Company
|
new Company
|
||||||
{
|
{
|
||||||
|
Id = 1,
|
||||||
Name = "Intel",
|
Name = "Intel",
|
||||||
// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
|
// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
|
||||||
Nip = "9570752316",
|
Nip = "9570752316",
|
||||||
@ -76,6 +67,7 @@ namespace InternshipSystem.Repository
|
|||||||
},
|
},
|
||||||
new Company
|
new Company
|
||||||
{
|
{
|
||||||
|
Id = 2,
|
||||||
Name = "Asseco Poland",
|
Name = "Asseco Poland",
|
||||||
// SiteAddress = new Uri("http://pl.asseco.com"),
|
// SiteAddress = new Uri("http://pl.asseco.com"),
|
||||||
Nip = "5842068320",
|
Nip = "5842068320",
|
||||||
@ -110,183 +102,49 @@ namespace InternshipSystem.Repository
|
|||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FillInternshipTypes()
|
|
||||||
{
|
|
||||||
var internshipTypes = new List<InternshipType>
|
|
||||||
{
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa o organizację praktyki",
|
|
||||||
LabelEng = "Internship agreement",
|
|
||||||
Description = "Praktyka bezpłatna",
|
|
||||||
DescriptionEng = "Free internship",
|
|
||||||
RequireInsurance = true
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa o praktykę absolwencką",
|
|
||||||
LabelEng = "Graduate internship agreement",
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa o staż bezpłatny",
|
|
||||||
LabelEng = "Free apprenticeship agreement",
|
|
||||||
RequireInsurance = true
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa o staż płatny",
|
|
||||||
LabelEng = "Paid apprenticeship agreement",
|
|
||||||
Description = "np. staż przemysłowy",
|
|
||||||
DescriptionEng = "e.g. industrial apprenticeship",
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Praktyka Zagraniczna",
|
|
||||||
LabelEng = "Foreign Internship",
|
|
||||||
Description = "IAESTE, ERASMUS",
|
|
||||||
DescriptionEng = "IAESTE, ERASMUS",
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa o pracę",
|
|
||||||
LabelEng = "Contract of employment",
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa o dzieło (w tym B2B)",
|
|
||||||
LabelEng = "Contract work (including B2B)",
|
|
||||||
},
|
|
||||||
new InternshipType
|
|
||||||
{
|
|
||||||
Label = "Umowa zlecenia (w tym B2B)",
|
|
||||||
LabelEng = "Contract of mandate (including B2B)",
|
|
||||||
RequireDeansApproval = true
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await Context.InternshipTypes.AddRangeAsync(internshipTypes);
|
|
||||||
await Context.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task FillEditions()
|
public async Task FillEditions()
|
||||||
{
|
{
|
||||||
var editions = new List<Edition>
|
var editions = new List<Edition>
|
||||||
{
|
{
|
||||||
new Edition
|
new Edition
|
||||||
{
|
{
|
||||||
Id = Guid.Parse("138da8a3-855c-4b17-9bd2-5f357679efa9"),
|
EditionStart = new DateTime(2000, 5, 10),
|
||||||
EditionStart = new DateTime(2020, 5, 10),
|
EditionFinish = new DateTime(2000, 11, 10),
|
||||||
EditionFinish = new DateTime(2020, 12, 10),
|
ReportingStart = new DateTime(2000, 9, 30),
|
||||||
ReportingStart = new DateTime(2020, 9, 30),
|
|
||||||
AvailableSubjects = new List<EditionSubject>
|
AvailableSubjects = new List<EditionSubject>
|
||||||
{
|
{
|
||||||
new EditionSubject
|
new EditionSubject
|
||||||
{
|
{
|
||||||
Subject = new InternshipSubject
|
Subject = new InternshipSubject
|
||||||
{
|
{
|
||||||
Description = "Modelowanie baz danych",
|
Description = "Modelowanie baz danych"
|
||||||
DescriptionEng = "Database modeling",
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new EditionSubject
|
new EditionSubject
|
||||||
{
|
{
|
||||||
Subject = new InternshipSubject
|
Subject = new InternshipSubject
|
||||||
{
|
{
|
||||||
Description = "Oprogramowywanie kart graficznych",
|
Description = "Oprogramowywanie kart graficznych"
|
||||||
DescriptionEng = "Graphics card software",
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new EditionSubject
|
new EditionSubject
|
||||||
{
|
{
|
||||||
Subject = new InternshipSubject
|
Subject = new InternshipSubject
|
||||||
{
|
{
|
||||||
Description = "Projektowanie UI",
|
Description = "Projektowanie UI"
|
||||||
DescriptionEng = "UI design",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Course = new Course
|
Course = new Course
|
||||||
{
|
{
|
||||||
Name = "Informatyka",
|
Name = "Informatyka",
|
||||||
NameEng = "Informatics",
|
|
||||||
},
|
},
|
||||||
AvailableInternshipTypes = new List<EditionInternshipType>
|
AvailableInternshipTypes = new List<EditionInternshipType>
|
||||||
{
|
{
|
||||||
new EditionInternshipType
|
new EditionInternshipType() { InternshipType = InternshipType.UOP },
|
||||||
{
|
new EditionInternshipType() { InternshipType = InternshipType.UZ },
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę"))
|
new EditionInternshipType() { InternshipType = InternshipType.UD },
|
||||||
},
|
new EditionInternshipType() { InternshipType = InternshipType.FreeInternship },
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)"))
|
|
||||||
},
|
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło (w tym B2B)"))
|
|
||||||
},
|
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o organizację praktyki"))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Internships = new List<Internship>(),
|
|
||||||
},
|
|
||||||
new Edition
|
|
||||||
{
|
|
||||||
Id = Guid.Parse("bd0da085-8e51-400d-9630-bdab3f9f6cc8"),
|
|
||||||
EditionStart = new DateTime(2019, 5, 10),
|
|
||||||
EditionFinish = new DateTime(2019, 12, 10),
|
|
||||||
ReportingStart = new DateTime(2019, 9, 30),
|
|
||||||
AvailableSubjects = new List<EditionSubject>
|
|
||||||
{
|
|
||||||
new EditionSubject
|
|
||||||
{
|
|
||||||
Subject = new InternshipSubject
|
|
||||||
{
|
|
||||||
Description = "Modelowanie baz danych",
|
|
||||||
DescriptionEng = "Database modeling",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new EditionSubject
|
|
||||||
{
|
|
||||||
Subject = new InternshipSubject
|
|
||||||
{
|
|
||||||
Description = "Oprogramowywanie kart graficznych",
|
|
||||||
DescriptionEng = "Graphics card software",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new EditionSubject
|
|
||||||
{
|
|
||||||
Subject = new InternshipSubject
|
|
||||||
{
|
|
||||||
Description = "Projektowanie UI",
|
|
||||||
DescriptionEng = "UI design",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Course = new Course
|
|
||||||
{
|
|
||||||
Name = "Inżynieria Biomedyczna",
|
|
||||||
NameEng = "Biomedical Engineering",
|
|
||||||
},
|
|
||||||
AvailableInternshipTypes = new List<EditionInternshipType>
|
|
||||||
{
|
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę"))
|
|
||||||
},
|
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)"))
|
|
||||||
},
|
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło (w tym B2B)"))
|
|
||||||
},
|
|
||||||
new EditionInternshipType
|
|
||||||
{
|
|
||||||
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o organizację praktyki"))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Internships = new List<Internship>(),
|
Internships = new List<Internship>(),
|
||||||
}
|
}
|
||||||
@ -298,35 +156,30 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
new Internship
|
new Internship
|
||||||
{
|
{
|
||||||
Documentation = new List<Document>
|
|
||||||
{
|
|
||||||
new Document
|
|
||||||
{
|
|
||||||
Description = "doc",
|
|
||||||
Type = DocumentType.IppScan
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Student = new Student
|
Student = new Student
|
||||||
{
|
{
|
||||||
FirstName = "Jan",
|
FirstName = "Jan",
|
||||||
LastName = "Kowalski",
|
LastName = "Kowalski",
|
||||||
AlbumNumber = 123456,
|
AlbumNumber = 123456,
|
||||||
Email = "s123456@student.pg.edu.pl",
|
Email = "s123456@student.pg.edu.pl",
|
||||||
|
Semester = 4,
|
||||||
},
|
},
|
||||||
InternshipRegistration = new InternshipRegistration
|
InternshipRegistration = new InternshipRegistration
|
||||||
{
|
{
|
||||||
Company = Context.Companies.First(c => c.Name.Equals("Intel")),
|
Company = Context.Companies.First(c => c.Id.Equals(1)), //Intel
|
||||||
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")),
|
Type = InternshipType.UOP,
|
||||||
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,
|
||||||
BranchAddress =
|
BranchAddress =
|
||||||
Context.Companies
|
Context.Companies
|
||||||
.Include(c => c.Branches)
|
.Include(c => c.Branches)
|
||||||
.First(c => c.Name.Equals("Intel"))
|
.First(c => c.Id.Equals(1))
|
||||||
.Branches
|
.Branches
|
||||||
.First(),
|
.First(),
|
||||||
|
},
|
||||||
|
InternshipProgram = new InternshipProgram
|
||||||
|
{
|
||||||
Mentor = new Mentor
|
Mentor = new Mentor
|
||||||
{
|
{
|
||||||
FirstName = "Horacy",
|
FirstName = "Horacy",
|
||||||
@ -334,7 +187,7 @@ namespace InternshipSystem.Repository
|
|||||||
Email = "howos@intel.com",
|
Email = "howos@intel.com",
|
||||||
PhoneNumber = "605-555-555",
|
PhoneNumber = "605-555-555",
|
||||||
},
|
},
|
||||||
Subjects = new List<ProgramSubject>
|
ChosenSubjects = new List<ProgramSubject>
|
||||||
{
|
{
|
||||||
new ProgramSubject
|
new ProgramSubject
|
||||||
{
|
{
|
||||||
@ -350,7 +203,6 @@ namespace InternshipSystem.Repository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Report = Report.Create()
|
|
||||||
},
|
},
|
||||||
new Internship
|
new Internship
|
||||||
{
|
{
|
||||||
@ -360,21 +212,24 @@ namespace InternshipSystem.Repository
|
|||||||
LastName = "Kołek",
|
LastName = "Kołek",
|
||||||
AlbumNumber = 102137,
|
AlbumNumber = 102137,
|
||||||
Email = "s102137@student.pg.edu.pl",
|
Email = "s102137@student.pg.edu.pl",
|
||||||
|
Semester = 6,
|
||||||
},
|
},
|
||||||
InternshipRegistration = new InternshipRegistration
|
InternshipRegistration = new InternshipRegistration
|
||||||
{
|
{
|
||||||
Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")),
|
Company = Context.Companies.First(c => c.Id.Equals(2)), //Asseco
|
||||||
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")),
|
Type = InternshipType.UZ,
|
||||||
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,
|
||||||
BranchAddress =
|
BranchAddress =
|
||||||
Context.Companies
|
Context.Companies
|
||||||
.Include(c => c.Branches)
|
.Include(c => c.Branches)
|
||||||
.First(c => c.Name.Equals("Asseco Poland"))
|
.First(c => c.Id.Equals(2))
|
||||||
.Branches
|
.Branches
|
||||||
.First(),
|
.First(),
|
||||||
|
},
|
||||||
|
InternshipProgram = new InternshipProgram
|
||||||
|
{
|
||||||
Mentor = new Mentor
|
Mentor = new Mentor
|
||||||
{
|
{
|
||||||
FirstName = "Henryk",
|
FirstName = "Henryk",
|
||||||
@ -382,7 +237,7 @@ namespace InternshipSystem.Repository
|
|||||||
Email = "hepol@asseco.pl",
|
Email = "hepol@asseco.pl",
|
||||||
PhoneNumber = "555-525-545",
|
PhoneNumber = "555-525-545",
|
||||||
},
|
},
|
||||||
Subjects = new List<ProgramSubject>
|
ChosenSubjects = new List<ProgramSubject>
|
||||||
{
|
{
|
||||||
new ProgramSubject
|
new ProgramSubject
|
||||||
{
|
{
|
||||||
@ -398,39 +253,45 @@ namespace InternshipSystem.Repository
|
|||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FillStaticPages()
|
// new InternshipType
|
||||||
{
|
// {
|
||||||
var staticPages = new List<StaticPage>
|
// Type = "FreeInternship",
|
||||||
{
|
// Description = "Praktyka bezpłatna",
|
||||||
new StaticPage
|
// },
|
||||||
{
|
// new InternshipType
|
||||||
AccessName = "regulations",
|
// {
|
||||||
Title = "Regulamin Praktyk",
|
// Type = "GraduateInternship"
|
||||||
TitleEng = "Internship Regulations",
|
// },
|
||||||
Content =
|
// new InternshipType
|
||||||
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; <b>Duo Reges: constructio interrete.</b> <i>Eam tum adesse, cum dolor omnis absit;</i> Sed ad bona praeterita redeamus. <mark>Facillimum id quidem est, inquam.</mark> Apud ceteros autem philosophos, qui quaesivit aliquid, tacet; </p>" +
|
// {
|
||||||
"<p><a href=\"http://loripsum.net/\" target=\"_blank\">Quorum altera prosunt, nocent altera.</a> Eam stabilem appellas. <i>Sed nimis multa.</i> Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? <mark>Quod quidem nobis non saepe contingit.</mark> Si autem id non concedatur, non continuo vita beata tollitur. " +
|
// Type = "FreeApprenticeship"
|
||||||
"<a href=\"http://loripsum.net/\" target=\"_blank\">Illum mallem levares, quo optimum atque humanissimum virum, Cn.</a> <i>Id est enim, de quo quaerimus.</i> </p><p>Ille vero, si insipiens-quo certe, quoniam tyrannus -, numquam beatus; Sin dicit obscurari quaedam nec apparere, quia valde parva sint, nos quoque concedimus; Et quod est munus, quod opus sapientiae? Ab hoc autem quaedam non melius quam veteres, quaedam omnino relicta. </p>" +
|
// },
|
||||||
"<p>Prosto z bazy danych ;D</p>",
|
// new InternshipType
|
||||||
ContentEng =
|
// {
|
||||||
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; <b>Duo Reges: constructio interrete.</b> <i>Eam tum adesse, cum dolor omnis absit;</i> Sed ad bona praeterita redeamus. <mark>Facillimum id quidem est, inquam.</mark> Apud ceteros autem philosophos, qui quaesivit aliquid, tacet; </p>" +
|
// Type = "PaidApprenticeship",
|
||||||
"<p><a href=\"http://loripsum.net/\" target=\"_blank\">Quorum altera prosunt, nocent altera.</a> Eam stabilem appellas. <i>Sed nimis multa.</i> Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? <mark>Quod quidem nobis non saepe contingit.</mark> Si autem id non concedatur, non continuo vita beata tollitur. " +
|
// Description = "np. przemysłowy"
|
||||||
"<a href=\"http://loripsum.net/\" target=\"_blank\">Illum mallem levares, quo optimum atque humanissimum virum, Cn.</a> <i>Id est enim, de quo quaerimus.</i> </p><p>Ille vero, si insipiens-quo certe, quoniam tyrannus -, numquam beatus; Sin dicit obscurari quaedam nec apparere, quia valde parva sint, nos quoque concedimus; Et quod est munus, quod opus sapientiae? Ab hoc autem quaedam non melius quam veteres, quaedam omnino relicta. </p>" +
|
// },
|
||||||
"<p>Straight from the database ;D</p>",
|
// new InternshipType
|
||||||
},
|
// {
|
||||||
new StaticPage
|
// Type = "ForeignInternship",
|
||||||
{
|
// Description = "np. IAESTE, ERASMUS"
|
||||||
AccessName = "info",
|
// },
|
||||||
Title = "Informacje",
|
// new InternshipType
|
||||||
TitleEng = "Information",
|
// {
|
||||||
Content =
|
// Type = "UOP"
|
||||||
"<p>Nowe zmiany: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
// },
|
||||||
ContentEng =
|
// new InternshipType
|
||||||
"<p>New changes: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
// {
|
||||||
}
|
// Type = "UD"
|
||||||
};
|
// },
|
||||||
await Context.StaticPages.AddRangeAsync(staticPages);
|
// new InternshipType
|
||||||
await Context.SaveChangesAsync();
|
// {
|
||||||
}
|
// Type = "UZ"
|
||||||
|
// },
|
||||||
|
// new InternshipType
|
||||||
|
// {
|
||||||
|
// Type = "Other",
|
||||||
|
// Description = "Należy wprowadzić samodzielnie"
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,5 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Core;
|
||||||
using InternshipSystem.Core.Entity;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using InternshipSystem.Core.UglyOrmArtifacts;
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
@ -12,13 +9,8 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
public DbSet<Company> Companies { get; set; }
|
public DbSet<Company> Companies { get; set; }
|
||||||
public DbSet<Edition> Editions { get; set; }
|
public DbSet<Edition> Editions { get; set; }
|
||||||
public DbSet<StaticPage> StaticPages { get; set; }
|
|
||||||
public DbSet<InternshipType> InternshipTypes { get; set; }
|
|
||||||
public DbSet<Student> Students { get; set; }
|
|
||||||
public DbSet<Course> Courses { get; set; }
|
|
||||||
public DbSet<Internship> Internships { get; set; }
|
|
||||||
|
|
||||||
public DbSet<ReportField> ReportFields { get; set; }
|
public DbSet<Student> Students { get; set; }
|
||||||
|
|
||||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||||
: base(options)
|
: base(options)
|
||||||
@ -31,32 +23,31 @@ namespace InternshipSystem.Repository
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
modelBuilder.Entity<Company>()
|
||||||
|
.Property(company => company.Nip)
|
||||||
|
.HasConversion<string>(
|
||||||
|
nip => nip,
|
||||||
|
s => (Nip)s);
|
||||||
|
|
||||||
modelBuilder.Entity<BranchOffice>()
|
modelBuilder.Entity<BranchOffice>()
|
||||||
.OwnsOne(bo => bo.Address);
|
.OwnsOne(bo => bo.Address);
|
||||||
|
|
||||||
|
modelBuilder.Entity<InternshipProgram>()
|
||||||
modelBuilder.Entity<InternshipRegistration>()
|
.OwnsOne(ip => ip.Mentor)
|
||||||
.OwnsOne(ir => ir.Mentor);
|
.Property(mentor => mentor.PhoneNumber)
|
||||||
|
.HasConversion<string>(
|
||||||
modelBuilder.Entity<DocumentScan>(builder =>
|
number => number,
|
||||||
{
|
s => (PhoneNumber)s);
|
||||||
builder
|
|
||||||
.HasKey(scan => scan.DocumentId);
|
|
||||||
|
|
||||||
builder
|
|
||||||
.HasOne(s => s.Document)
|
|
||||||
.WithOne(d => d.Scan);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<ProgramSubject>(builder =>
|
modelBuilder.Entity<ProgramSubject>(builder =>
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.HasKey(subject => new { InternshipProgramId = subject.InternshipRegistrationId, subject.InternshipSubjectId });
|
.HasKey(subject => new { subject.InternshipProgramId, subject.InternshipSubjectId });
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasOne(k => k.Registration)
|
.HasOne(k => k.Program)
|
||||||
.WithMany(model => model.Subjects)
|
.WithMany(model => model.ChosenSubjects)
|
||||||
.HasForeignKey(subject => subject.InternshipRegistrationId);
|
.HasForeignKey(subject => subject.InternshipProgramId);
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasOne(k => k.Subject)
|
.HasOne(k => k.Subject)
|
||||||
@ -64,22 +55,6 @@ namespace InternshipSystem.Repository
|
|||||||
.HasForeignKey(subject => subject.InternshipSubjectId);
|
.HasForeignKey(subject => subject.InternshipSubjectId);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<EditionInternshipType>(builder =>
|
|
||||||
{
|
|
||||||
builder
|
|
||||||
.HasKey(type => new { type.EditionId, type.InternshipTypeId});
|
|
||||||
|
|
||||||
builder
|
|
||||||
.HasOne(k => k.Edition)
|
|
||||||
.WithMany(model => model.AvailableInternshipTypes)
|
|
||||||
.HasForeignKey(p => p.EditionId);
|
|
||||||
|
|
||||||
builder
|
|
||||||
.HasOne(k => k.InternshipType)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(type => type.InternshipTypeId);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<EditionSubject>(builder =>
|
modelBuilder.Entity<EditionSubject>(builder =>
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
@ -95,37 +70,6 @@ namespace InternshipSystem.Repository
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(subject => subject.InternshipSubjectId);
|
.HasForeignKey(subject => subject.InternshipSubjectId);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<ReportFieldEdition>(builder =>
|
|
||||||
{
|
|
||||||
builder
|
|
||||||
.HasKey(e => new {e.EditionId, e.ReportFieldId});
|
|
||||||
|
|
||||||
builder
|
|
||||||
.HasOne(e => e.Edition)
|
|
||||||
.WithMany(edition => edition.ReportSchema)
|
|
||||||
.HasForeignKey(r => r.EditionId);
|
|
||||||
|
|
||||||
builder
|
|
||||||
.HasOne(e => e.Field)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(r => r.ReportFieldId);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<ReportField>()
|
|
||||||
.HasDiscriminator<string>("field_discrimnator")
|
|
||||||
.HasValue<ReportField>("single")
|
|
||||||
.HasValue<ReportChoiceField>("choice");
|
|
||||||
|
|
||||||
modelBuilder.Entity<ReportChoiceField>()
|
|
||||||
.Property(r => r.Choices)
|
|
||||||
.HasConversion(
|
|
||||||
a => string.Join('#', a),
|
|
||||||
s => s.Split('#', StringSplitOptions.RemoveEmptyEntries));
|
|
||||||
|
|
||||||
modelBuilder.Entity<Report>()
|
|
||||||
.Property(r => r.Value)
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,10 +9,10 @@ namespace InternshipSystem.Repository {
|
|||||||
|
|
||||||
public InternshipDbContext CreateDbContext(string[] args)
|
public InternshipDbContext CreateDbContext(string[] args)
|
||||||
{
|
{
|
||||||
var optionsBuilder = new DbContextOptionsBuilder<InternshipDbContext>();
|
var optionsBulider = new DbContextOptionsBuilder<InternshipDbContext>();
|
||||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu");
|
optionsBulider.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu");
|
||||||
|
|
||||||
return new InternshipDbContext(optionsBuilder.Options);
|
return new InternshipDbContext(optionsBulider.Options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,794 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Repository.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(InternshipDbContext))]
|
|
||||||
[Migration("20210110210810_Init")]
|
|
||||||
partial class Init
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
|
||||||
.HasAnnotation("ProductVersion", "3.1.4")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<long?>("CompanyId")
|
|
||||||
.HasColumnName("company_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long>("Provider")
|
|
||||||
.HasColumnName("provider")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_branch_office");
|
|
||||||
|
|
||||||
b.HasIndex("CompanyId")
|
|
||||||
.HasName("ix_branch_office_company_id");
|
|
||||||
|
|
||||||
b.ToTable("branch_office");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnName("name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Nip")
|
|
||||||
.HasColumnName("nip")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long>("Provider")
|
|
||||||
.HasColumnName("provider")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_companies");
|
|
||||||
|
|
||||||
b.ToTable("companies");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("ChangeStateComment")
|
|
||||||
.HasColumnName("change_state_comment")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long?>("InternshipId")
|
|
||||||
.HasColumnName("internship_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnName("state")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("Type")
|
|
||||||
.HasColumnName("type")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_document");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipId")
|
|
||||||
.HasName("ix_document_internship_id");
|
|
||||||
|
|
||||||
b.ToTable("document");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("DocumentId")
|
|
||||||
.HasColumnName("document_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<byte[]>("File")
|
|
||||||
.HasColumnName("file")
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<string>("Filename")
|
|
||||||
.HasColumnName("filename")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Mime")
|
|
||||||
.HasColumnName("mime")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long>("Size")
|
|
||||||
.HasColumnName("size")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("DocumentId")
|
|
||||||
.HasName("pk_document_scan");
|
|
||||||
|
|
||||||
b.ToTable("document_scan");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long?>("CourseId")
|
|
||||||
.HasColumnName("course_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EditionFinish")
|
|
||||||
.HasColumnName("edition_finish")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EditionStart")
|
|
||||||
.HasColumnName("edition_start")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("ReportingStart")
|
|
||||||
.HasColumnName("reporting_start")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_editions");
|
|
||||||
|
|
||||||
b.HasIndex("CourseId")
|
|
||||||
.HasName("ix_editions_course_id");
|
|
||||||
|
|
||||||
b.ToTable("editions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Course", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnName("name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("NameEng")
|
|
||||||
.HasColumnName("name_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_courses");
|
|
||||||
|
|
||||||
b.ToTable("courses");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<Guid?>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<float?>("Grade")
|
|
||||||
.HasColumnName("grade")
|
|
||||||
.HasColumnType("real");
|
|
||||||
|
|
||||||
b.Property<long?>("InternshipRegistrationId")
|
|
||||||
.HasColumnName("internship_registration_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long?>("ReportId")
|
|
||||||
.HasColumnName("report_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long?>("StudentId")
|
|
||||||
.HasColumnName("student_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internships");
|
|
||||||
|
|
||||||
b.HasIndex("EditionId")
|
|
||||||
.HasName("ix_internships_edition_id");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipRegistrationId")
|
|
||||||
.HasName("ix_internships_internship_registration_id");
|
|
||||||
|
|
||||||
b.HasIndex("ReportId")
|
|
||||||
.HasName("ix_internships_report_id");
|
|
||||||
|
|
||||||
b.HasIndex("StudentId")
|
|
||||||
.HasName("ix_internships_student_id");
|
|
||||||
|
|
||||||
b.ToTable("internships");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<long?>("BranchAddressId")
|
|
||||||
.HasColumnName("branch_address_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<string>("ChangeStateComment")
|
|
||||||
.HasColumnName("change_state_comment")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long?>("CompanyId")
|
|
||||||
.HasColumnName("company_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<int>("DeclaredHours")
|
|
||||||
.HasColumnName("declared_hours")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("End")
|
|
||||||
.HasColumnName("end")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Start")
|
|
||||||
.HasColumnName("start")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnName("state")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("SubmissionDate")
|
|
||||||
.HasColumnName("submission_date")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<long?>("TypeId")
|
|
||||||
.HasColumnName("type_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internship_registration");
|
|
||||||
|
|
||||||
b.HasIndex("BranchAddressId")
|
|
||||||
.HasName("ix_internship_registration_branch_address_id");
|
|
||||||
|
|
||||||
b.HasIndex("CompanyId")
|
|
||||||
.HasName("ix_internship_registration_company_id");
|
|
||||||
|
|
||||||
b.HasIndex("TypeId")
|
|
||||||
.HasName("ix_internship_registration_type_id");
|
|
||||||
|
|
||||||
b.ToTable("internship_registration");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DescriptionEng")
|
|
||||||
.HasColumnName("description_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internship_subject");
|
|
||||||
|
|
||||||
b.ToTable("internship_subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DescriptionEng")
|
|
||||||
.HasColumnName("description_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Label")
|
|
||||||
.HasColumnName("label")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LabelEng")
|
|
||||||
.HasColumnName("label_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("RequireDeansApproval")
|
|
||||||
.HasColumnName("require_deans_approval")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internship_types");
|
|
||||||
|
|
||||||
b.ToTable("internship_types");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DescriptionEng")
|
|
||||||
.HasColumnName("description_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("FieldType")
|
|
||||||
.HasColumnName("field_type")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Label")
|
|
||||||
.HasColumnName("label")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LabelEng")
|
|
||||||
.HasColumnName("label_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("field_discrimnator")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnName("field_discrimnator")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_report_fields");
|
|
||||||
|
|
||||||
b.ToTable("report_fields");
|
|
||||||
|
|
||||||
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnName("state")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnName("value")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_report");
|
|
||||||
|
|
||||||
b.ToTable("report");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.StaticPage", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("AccessName")
|
|
||||||
.HasColumnName("access_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Content")
|
|
||||||
.HasColumnName("content")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ContentEng")
|
|
||||||
.HasColumnName("content_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Title")
|
|
||||||
.HasColumnName("title")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("TitleEng")
|
|
||||||
.HasColumnName("title_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_static_pages");
|
|
||||||
|
|
||||||
b.ToTable("static_pages");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<int>("AlbumNumber")
|
|
||||||
.HasColumnName("album_number")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Course")
|
|
||||||
.HasColumnName("course")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasColumnName("email")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.HasColumnName("first_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.HasColumnName("last_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("Semester")
|
|
||||||
.HasColumnName("semester")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_students");
|
|
||||||
|
|
||||||
b.ToTable("students");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long>("InternshipTypeId")
|
|
||||||
.HasColumnName("internship_type_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("EditionId", "InternshipTypeId")
|
|
||||||
.HasName("pk_edition_internship_type");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipTypeId")
|
|
||||||
.HasName("ix_edition_internship_type_internship_type_id");
|
|
||||||
|
|
||||||
b.ToTable("edition_internship_type");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long>("InternshipSubjectId")
|
|
||||||
.HasColumnName("internship_subject_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("EditionId", "InternshipSubjectId")
|
|
||||||
.HasName("pk_edition_subject");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipSubjectId")
|
|
||||||
.HasName("ix_edition_subject_internship_subject_id");
|
|
||||||
|
|
||||||
b.ToTable("edition_subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("InternshipRegistrationId")
|
|
||||||
.HasColumnName("internship_registration_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long>("InternshipSubjectId")
|
|
||||||
.HasColumnName("internship_subject_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
|
|
||||||
.HasName("pk_program_subject");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipSubjectId")
|
|
||||||
.HasName("ix_program_subject_internship_subject_id");
|
|
||||||
|
|
||||||
b.ToTable("program_subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long>("ReportFieldId")
|
|
||||||
.HasColumnName("report_field_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("EditionId", "ReportFieldId")
|
|
||||||
.HasName("pk_report_field_edition");
|
|
||||||
|
|
||||||
b.HasIndex("ReportFieldId")
|
|
||||||
.HasName("ix_report_field_edition_report_field_id");
|
|
||||||
|
|
||||||
b.ToTable("report_field_edition");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
|
|
||||||
{
|
|
||||||
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
|
|
||||||
|
|
||||||
b.Property<string>("Choices")
|
|
||||||
.HasColumnName("choices")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("choice");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Company", null)
|
|
||||||
.WithMany("Branches")
|
|
||||||
.HasForeignKey("CompanyId")
|
|
||||||
.HasConstraintName("fk_branch_office_companies_company_id");
|
|
||||||
|
|
||||||
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
|
|
||||||
{
|
|
||||||
b1.Property<long>("BranchOfficeId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b1.Property<string>("Building")
|
|
||||||
.HasColumnName("building")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("City")
|
|
||||||
.HasColumnName("city")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("Country")
|
|
||||||
.HasColumnName("country")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("PostalCode")
|
|
||||||
.HasColumnName("postal_code")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("Street")
|
|
||||||
.HasColumnName("street")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.HasKey("BranchOfficeId")
|
|
||||||
.HasName("pk_branch_office");
|
|
||||||
|
|
||||||
b1.ToTable("branch_office");
|
|
||||||
|
|
||||||
b1.WithOwner()
|
|
||||||
.HasForeignKey("BranchOfficeId")
|
|
||||||
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
|
|
||||||
.WithMany("Documentation")
|
|
||||||
.HasForeignKey("InternshipId")
|
|
||||||
.HasConstraintName("fk_document_internships_internship_id");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Document", "Document")
|
|
||||||
.WithOne("Scan")
|
|
||||||
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
|
|
||||||
.HasConstraintName("fk_document_scan_document_document_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("CourseId")
|
|
||||||
.HasConstraintName("fk_editions_courses_course_id");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("Internships")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_internships_editions_edition_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
|
||||||
.HasConstraintName("fk_internships_internship_registration_internship_registration");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Report", "Report")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReportId")
|
|
||||||
.HasConstraintName("fk_internships_report_report_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Student", "Student")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("StudentId")
|
|
||||||
.HasConstraintName("fk_internships_students_student_id");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("BranchAddressId")
|
|
||||||
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Company", "Company")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("CompanyId")
|
|
||||||
.HasConstraintName("fk_internship_registration_companies_company_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("TypeId")
|
|
||||||
.HasConstraintName("fk_internship_registration_internship_types_type_id");
|
|
||||||
|
|
||||||
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
|
|
||||||
{
|
|
||||||
b1.Property<long>("InternshipRegistrationId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b1.Property<string>("Email")
|
|
||||||
.HasColumnName("email")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("FirstName")
|
|
||||||
.HasColumnName("first_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("LastName")
|
|
||||||
.HasColumnName("last_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("PhoneNumber")
|
|
||||||
.HasColumnName("phone_number")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.HasKey("InternshipRegistrationId")
|
|
||||||
.HasName("pk_internship_registration");
|
|
||||||
|
|
||||||
b1.ToTable("internship_registration");
|
|
||||||
|
|
||||||
b1.WithOwner()
|
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
|
||||||
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("AvailableInternshipTypes")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_edition_internship_type_editions_edition_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "InternshipType")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipTypeId")
|
|
||||||
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("AvailableSubjects")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_edition_subject_editions_edition_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipSubjectId")
|
|
||||||
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "Registration")
|
|
||||||
.WithMany("Subjects")
|
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
|
||||||
.HasConstraintName("fk_program_subject_internship_registration_internship_registrat")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipSubjectId")
|
|
||||||
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("ReportSchema")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_report_field_edition_editions_edition_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReportFieldId")
|
|
||||||
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,537 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Repository.Migrations
|
|
||||||
{
|
|
||||||
public partial class Init : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "companies",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
nip = table.Column<string>(nullable: true),
|
|
||||||
name = table.Column<string>(nullable: true),
|
|
||||||
provider = table.Column<long>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_companies", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "courses",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
name = table.Column<string>(nullable: true),
|
|
||||||
name_eng = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_courses", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "internship_subject",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
description = table.Column<string>(nullable: true),
|
|
||||||
description_eng = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_internship_subject", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "internship_types",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
label = table.Column<string>(nullable: true),
|
|
||||||
label_eng = table.Column<string>(nullable: true),
|
|
||||||
description = table.Column<string>(nullable: true),
|
|
||||||
description_eng = table.Column<string>(nullable: true),
|
|
||||||
require_deans_approval = table.Column<bool>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_internship_types", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "report",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
state = table.Column<int>(nullable: false),
|
|
||||||
value = table.Column<string>(type: "jsonb", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_report", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "report_fields",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
label = table.Column<string>(nullable: true),
|
|
||||||
label_eng = table.Column<string>(nullable: true),
|
|
||||||
description = table.Column<string>(nullable: true),
|
|
||||||
description_eng = table.Column<string>(nullable: true),
|
|
||||||
field_type = table.Column<int>(nullable: false),
|
|
||||||
field_discrimnator = table.Column<string>(nullable: false),
|
|
||||||
choices = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_report_fields", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "static_pages",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
access_name = table.Column<string>(nullable: true),
|
|
||||||
title = table.Column<string>(nullable: true),
|
|
||||||
title_eng = table.Column<string>(nullable: true),
|
|
||||||
content = table.Column<string>(nullable: true),
|
|
||||||
content_eng = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_static_pages", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "students",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
album_number = table.Column<int>(nullable: false),
|
|
||||||
first_name = table.Column<string>(nullable: true),
|
|
||||||
last_name = table.Column<string>(nullable: true),
|
|
||||||
email = table.Column<string>(nullable: true),
|
|
||||||
course = table.Column<string>(nullable: true),
|
|
||||||
semester = table.Column<int>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_students", x => x.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "branch_office",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
street = table.Column<string>(nullable: true),
|
|
||||||
building = table.Column<string>(nullable: true),
|
|
||||||
city = table.Column<string>(nullable: true),
|
|
||||||
postal_code = table.Column<string>(nullable: true),
|
|
||||||
country = table.Column<string>(nullable: true),
|
|
||||||
provider = table.Column<long>(nullable: false),
|
|
||||||
company_id = table.Column<long>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_branch_office", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_branch_office_companies_company_id",
|
|
||||||
column: x => x.company_id,
|
|
||||||
principalTable: "companies",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "editions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<Guid>(nullable: false),
|
|
||||||
edition_start = table.Column<DateTime>(nullable: false),
|
|
||||||
edition_finish = table.Column<DateTime>(nullable: false),
|
|
||||||
reporting_start = table.Column<DateTime>(nullable: false),
|
|
||||||
course_id = table.Column<long>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_editions", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_editions_courses_course_id",
|
|
||||||
column: x => x.course_id,
|
|
||||||
principalTable: "courses",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "internship_registration",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
company_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),
|
|
||||||
end = table.Column<DateTime>(nullable: false),
|
|
||||||
first_name = table.Column<string>(nullable: true),
|
|
||||||
last_name = table.Column<string>(nullable: true),
|
|
||||||
email = table.Column<string>(nullable: true),
|
|
||||||
phone_number = table.Column<string>(nullable: true),
|
|
||||||
type_id = table.Column<long>(nullable: true),
|
|
||||||
declared_hours = table.Column<int>(nullable: false),
|
|
||||||
state = table.Column<int>(nullable: false),
|
|
||||||
change_state_comment = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_internship_registration", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internship_registration_branch_office_branch_address_id",
|
|
||||||
column: x => x.branch_address_id,
|
|
||||||
principalTable: "branch_office",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internship_registration_companies_company_id",
|
|
||||||
column: x => x.company_id,
|
|
||||||
principalTable: "companies",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internship_registration_internship_types_type_id",
|
|
||||||
column: x => x.type_id,
|
|
||||||
principalTable: "internship_types",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "edition_internship_type",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
edition_id = table.Column<Guid>(nullable: false),
|
|
||||||
internship_type_id = table.Column<long>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_edition_internship_type", x => new { x.edition_id, x.internship_type_id });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_edition_internship_type_editions_edition_id",
|
|
||||||
column: x => x.edition_id,
|
|
||||||
principalTable: "editions",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_edition_internship_type_internship_types_internship_type_id",
|
|
||||||
column: x => x.internship_type_id,
|
|
||||||
principalTable: "internship_types",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "edition_subject",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
edition_id = table.Column<Guid>(nullable: false),
|
|
||||||
internship_subject_id = table.Column<long>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_edition_subject", x => new { x.edition_id, x.internship_subject_id });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_edition_subject_editions_edition_id",
|
|
||||||
column: x => x.edition_id,
|
|
||||||
principalTable: "editions",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_edition_subject_internship_subject_internship_subject_id",
|
|
||||||
column: x => x.internship_subject_id,
|
|
||||||
principalTable: "internship_subject",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "report_field_edition",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
edition_id = table.Column<Guid>(nullable: false),
|
|
||||||
report_field_id = table.Column<long>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_report_field_edition", x => new { x.edition_id, x.report_field_id });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_report_field_edition_editions_edition_id",
|
|
||||||
column: x => x.edition_id,
|
|
||||||
principalTable: "editions",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_report_field_edition_report_fields_report_field_id",
|
|
||||||
column: x => x.report_field_id,
|
|
||||||
principalTable: "report_fields",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "internships",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
student_id = table.Column<long>(nullable: true),
|
|
||||||
internship_registration_id = table.Column<long>(nullable: true),
|
|
||||||
report_id = table.Column<long>(nullable: true),
|
|
||||||
edition_id = table.Column<Guid>(nullable: true),
|
|
||||||
grade = table.Column<float>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_internships", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internships_editions_edition_id",
|
|
||||||
column: x => x.edition_id,
|
|
||||||
principalTable: "editions",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internships_internship_registration_internship_registration",
|
|
||||||
column: x => x.internship_registration_id,
|
|
||||||
principalTable: "internship_registration",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internships_report_report_id",
|
|
||||||
column: x => x.report_id,
|
|
||||||
principalTable: "report",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_internships_students_student_id",
|
|
||||||
column: x => x.student_id,
|
|
||||||
principalTable: "students",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "program_subject",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
internship_registration_id = table.Column<long>(nullable: false),
|
|
||||||
internship_subject_id = table.Column<long>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_program_subject", x => new { x.internship_registration_id, x.internship_subject_id });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_program_subject_internship_registration_internship_registrat",
|
|
||||||
column: x => x.internship_registration_id,
|
|
||||||
principalTable: "internship_registration",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_program_subject_internship_subject_internship_subject_id",
|
|
||||||
column: x => x.internship_subject_id,
|
|
||||||
principalTable: "internship_subject",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "document",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<long>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
description = table.Column<string>(nullable: true),
|
|
||||||
type = table.Column<int>(nullable: false),
|
|
||||||
state = table.Column<int>(nullable: false),
|
|
||||||
change_state_comment = table.Column<string>(nullable: true),
|
|
||||||
internship_id = table.Column<long>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_document", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_document_internships_internship_id",
|
|
||||||
column: x => x.internship_id,
|
|
||||||
principalTable: "internships",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "document_scan",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
document_id = table.Column<long>(nullable: false),
|
|
||||||
size = table.Column<long>(nullable: false),
|
|
||||||
filename = table.Column<string>(nullable: true),
|
|
||||||
mime = table.Column<string>(nullable: true),
|
|
||||||
file = table.Column<byte[]>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_document_scan", x => x.document_id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_document_scan_document_document_id",
|
|
||||||
column: x => x.document_id,
|
|
||||||
principalTable: "document",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_branch_office_company_id",
|
|
||||||
table: "branch_office",
|
|
||||||
column: "company_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_document_internship_id",
|
|
||||||
table: "document",
|
|
||||||
column: "internship_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_edition_internship_type_internship_type_id",
|
|
||||||
table: "edition_internship_type",
|
|
||||||
column: "internship_type_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_edition_subject_internship_subject_id",
|
|
||||||
table: "edition_subject",
|
|
||||||
column: "internship_subject_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_editions_course_id",
|
|
||||||
table: "editions",
|
|
||||||
column: "course_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_registration_branch_address_id",
|
|
||||||
table: "internship_registration",
|
|
||||||
column: "branch_address_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_registration_company_id",
|
|
||||||
table: "internship_registration",
|
|
||||||
column: "company_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_internship_registration_type_id",
|
|
||||||
table: "internship_registration",
|
|
||||||
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(
|
|
||||||
name: "ix_program_subject_internship_subject_id",
|
|
||||||
table: "program_subject",
|
|
||||||
column: "internship_subject_id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_report_field_edition_report_field_id",
|
|
||||||
table: "report_field_edition",
|
|
||||||
column: "report_field_id");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "document_scan");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "edition_internship_type");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "edition_subject");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "program_subject");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "report_field_edition");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "static_pages");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "document");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "internship_subject");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "report_fields");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "internships");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "editions");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "internship_registration");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "report");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "students");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "courses");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "branch_office");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "internship_types");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "companies");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,798 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using InternshipSystem.Repository;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Repository.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(InternshipDbContext))]
|
|
||||||
[Migration("20210111195519_Insurance")]
|
|
||||||
partial class Insurance
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
|
||||||
.HasAnnotation("ProductVersion", "3.1.4")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<long?>("CompanyId")
|
|
||||||
.HasColumnName("company_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long>("Provider")
|
|
||||||
.HasColumnName("provider")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_branch_office");
|
|
||||||
|
|
||||||
b.HasIndex("CompanyId")
|
|
||||||
.HasName("ix_branch_office_company_id");
|
|
||||||
|
|
||||||
b.ToTable("branch_office");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnName("name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Nip")
|
|
||||||
.HasColumnName("nip")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long>("Provider")
|
|
||||||
.HasColumnName("provider")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_companies");
|
|
||||||
|
|
||||||
b.ToTable("companies");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("ChangeStateComment")
|
|
||||||
.HasColumnName("change_state_comment")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long?>("InternshipId")
|
|
||||||
.HasColumnName("internship_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnName("state")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("Type")
|
|
||||||
.HasColumnName("type")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_document");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipId")
|
|
||||||
.HasName("ix_document_internship_id");
|
|
||||||
|
|
||||||
b.ToTable("document");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("DocumentId")
|
|
||||||
.HasColumnName("document_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<byte[]>("File")
|
|
||||||
.HasColumnName("file")
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<string>("Filename")
|
|
||||||
.HasColumnName("filename")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Mime")
|
|
||||||
.HasColumnName("mime")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long>("Size")
|
|
||||||
.HasColumnName("size")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("DocumentId")
|
|
||||||
.HasName("pk_document_scan");
|
|
||||||
|
|
||||||
b.ToTable("document_scan");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long?>("CourseId")
|
|
||||||
.HasColumnName("course_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EditionFinish")
|
|
||||||
.HasColumnName("edition_finish")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EditionStart")
|
|
||||||
.HasColumnName("edition_start")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("ReportingStart")
|
|
||||||
.HasColumnName("reporting_start")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_editions");
|
|
||||||
|
|
||||||
b.HasIndex("CourseId")
|
|
||||||
.HasName("ix_editions_course_id");
|
|
||||||
|
|
||||||
b.ToTable("editions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Course", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnName("name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("NameEng")
|
|
||||||
.HasColumnName("name_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_courses");
|
|
||||||
|
|
||||||
b.ToTable("courses");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<Guid?>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<float?>("Grade")
|
|
||||||
.HasColumnName("grade")
|
|
||||||
.HasColumnType("real");
|
|
||||||
|
|
||||||
b.Property<long?>("InternshipRegistrationId")
|
|
||||||
.HasColumnName("internship_registration_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long?>("ReportId")
|
|
||||||
.HasColumnName("report_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long?>("StudentId")
|
|
||||||
.HasColumnName("student_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internships");
|
|
||||||
|
|
||||||
b.HasIndex("EditionId")
|
|
||||||
.HasName("ix_internships_edition_id");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipRegistrationId")
|
|
||||||
.HasName("ix_internships_internship_registration_id");
|
|
||||||
|
|
||||||
b.HasIndex("ReportId")
|
|
||||||
.HasName("ix_internships_report_id");
|
|
||||||
|
|
||||||
b.HasIndex("StudentId")
|
|
||||||
.HasName("ix_internships_student_id");
|
|
||||||
|
|
||||||
b.ToTable("internships");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<long?>("BranchAddressId")
|
|
||||||
.HasColumnName("branch_address_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<string>("ChangeStateComment")
|
|
||||||
.HasColumnName("change_state_comment")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<long?>("CompanyId")
|
|
||||||
.HasColumnName("company_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<int>("DeclaredHours")
|
|
||||||
.HasColumnName("declared_hours")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("End")
|
|
||||||
.HasColumnName("end")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Start")
|
|
||||||
.HasColumnName("start")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnName("state")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("SubmissionDate")
|
|
||||||
.HasColumnName("submission_date")
|
|
||||||
.HasColumnType("timestamp without time zone");
|
|
||||||
|
|
||||||
b.Property<long?>("TypeId")
|
|
||||||
.HasColumnName("type_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internship_registration");
|
|
||||||
|
|
||||||
b.HasIndex("BranchAddressId")
|
|
||||||
.HasName("ix_internship_registration_branch_address_id");
|
|
||||||
|
|
||||||
b.HasIndex("CompanyId")
|
|
||||||
.HasName("ix_internship_registration_company_id");
|
|
||||||
|
|
||||||
b.HasIndex("TypeId")
|
|
||||||
.HasName("ix_internship_registration_type_id");
|
|
||||||
|
|
||||||
b.ToTable("internship_registration");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DescriptionEng")
|
|
||||||
.HasColumnName("description_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internship_subject");
|
|
||||||
|
|
||||||
b.ToTable("internship_subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DescriptionEng")
|
|
||||||
.HasColumnName("description_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Label")
|
|
||||||
.HasColumnName("label")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LabelEng")
|
|
||||||
.HasColumnName("label_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("RequireDeansApproval")
|
|
||||||
.HasColumnName("require_deans_approval")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<bool>("RequireInsurance")
|
|
||||||
.HasColumnName("require_insurance")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_internship_types");
|
|
||||||
|
|
||||||
b.ToTable("internship_types");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnName("description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("DescriptionEng")
|
|
||||||
.HasColumnName("description_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("FieldType")
|
|
||||||
.HasColumnName("field_type")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Label")
|
|
||||||
.HasColumnName("label")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LabelEng")
|
|
||||||
.HasColumnName("label_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("field_discrimnator")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnName("field_discrimnator")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_report_fields");
|
|
||||||
|
|
||||||
b.ToTable("report_fields");
|
|
||||||
|
|
||||||
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnName("state")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnName("value")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_report");
|
|
||||||
|
|
||||||
b.ToTable("report");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.StaticPage", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<string>("AccessName")
|
|
||||||
.HasColumnName("access_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Content")
|
|
||||||
.HasColumnName("content")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ContentEng")
|
|
||||||
.HasColumnName("content_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Title")
|
|
||||||
.HasColumnName("title")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("TitleEng")
|
|
||||||
.HasColumnName("title_eng")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_static_pages");
|
|
||||||
|
|
||||||
b.ToTable("static_pages");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<int>("AlbumNumber")
|
|
||||||
.HasColumnName("album_number")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Course")
|
|
||||||
.HasColumnName("course")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasColumnName("email")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.HasColumnName("first_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.HasColumnName("last_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("Semester")
|
|
||||||
.HasColumnName("semester")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("Id")
|
|
||||||
.HasName("pk_students");
|
|
||||||
|
|
||||||
b.ToTable("students");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long>("InternshipTypeId")
|
|
||||||
.HasColumnName("internship_type_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("EditionId", "InternshipTypeId")
|
|
||||||
.HasName("pk_edition_internship_type");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipTypeId")
|
|
||||||
.HasName("ix_edition_internship_type_internship_type_id");
|
|
||||||
|
|
||||||
b.ToTable("edition_internship_type");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long>("InternshipSubjectId")
|
|
||||||
.HasColumnName("internship_subject_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("EditionId", "InternshipSubjectId")
|
|
||||||
.HasName("pk_edition_subject");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipSubjectId")
|
|
||||||
.HasName("ix_edition_subject_internship_subject_id");
|
|
||||||
|
|
||||||
b.ToTable("edition_subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("InternshipRegistrationId")
|
|
||||||
.HasColumnName("internship_registration_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long>("InternshipSubjectId")
|
|
||||||
.HasColumnName("internship_subject_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
|
|
||||||
.HasName("pk_program_subject");
|
|
||||||
|
|
||||||
b.HasIndex("InternshipSubjectId")
|
|
||||||
.HasName("ix_program_subject_internship_subject_id");
|
|
||||||
|
|
||||||
b.ToTable("program_subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EditionId")
|
|
||||||
.HasColumnName("edition_id")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<long>("ReportFieldId")
|
|
||||||
.HasColumnName("report_field_id")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.HasKey("EditionId", "ReportFieldId")
|
|
||||||
.HasName("pk_report_field_edition");
|
|
||||||
|
|
||||||
b.HasIndex("ReportFieldId")
|
|
||||||
.HasName("ix_report_field_edition_report_field_id");
|
|
||||||
|
|
||||||
b.ToTable("report_field_edition");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
|
|
||||||
{
|
|
||||||
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
|
|
||||||
|
|
||||||
b.Property<string>("Choices")
|
|
||||||
.HasColumnName("choices")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("choice");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Company", null)
|
|
||||||
.WithMany("Branches")
|
|
||||||
.HasForeignKey("CompanyId")
|
|
||||||
.HasConstraintName("fk_branch_office_companies_company_id");
|
|
||||||
|
|
||||||
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
|
|
||||||
{
|
|
||||||
b1.Property<long>("BranchOfficeId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b1.Property<string>("Building")
|
|
||||||
.HasColumnName("building")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("City")
|
|
||||||
.HasColumnName("city")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("Country")
|
|
||||||
.HasColumnName("country")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("PostalCode")
|
|
||||||
.HasColumnName("postal_code")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("Street")
|
|
||||||
.HasColumnName("street")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.HasKey("BranchOfficeId")
|
|
||||||
.HasName("pk_branch_office");
|
|
||||||
|
|
||||||
b1.ToTable("branch_office");
|
|
||||||
|
|
||||||
b1.WithOwner()
|
|
||||||
.HasForeignKey("BranchOfficeId")
|
|
||||||
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
|
|
||||||
.WithMany("Documentation")
|
|
||||||
.HasForeignKey("InternshipId")
|
|
||||||
.HasConstraintName("fk_document_internships_internship_id");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Document", "Document")
|
|
||||||
.WithOne("Scan")
|
|
||||||
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
|
|
||||||
.HasConstraintName("fk_document_scan_document_document_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("CourseId")
|
|
||||||
.HasConstraintName("fk_editions_courses_course_id");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("Internships")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_internships_editions_edition_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
|
||||||
.HasConstraintName("fk_internships_internship_registration_internship_registration");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Report", "Report")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReportId")
|
|
||||||
.HasConstraintName("fk_internships_report_report_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Student", "Student")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("StudentId")
|
|
||||||
.HasConstraintName("fk_internships_students_student_id");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("BranchAddressId")
|
|
||||||
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Company", "Company")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("CompanyId")
|
|
||||||
.HasConstraintName("fk_internship_registration_companies_company_id");
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("TypeId")
|
|
||||||
.HasConstraintName("fk_internship_registration_internship_types_type_id");
|
|
||||||
|
|
||||||
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
|
|
||||||
{
|
|
||||||
b1.Property<long>("InternshipRegistrationId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnName("id")
|
|
||||||
.HasColumnType("bigint")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b1.Property<string>("Email")
|
|
||||||
.HasColumnName("email")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("FirstName")
|
|
||||||
.HasColumnName("first_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("LastName")
|
|
||||||
.HasColumnName("last_name")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.Property<string>("PhoneNumber")
|
|
||||||
.HasColumnName("phone_number")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b1.HasKey("InternshipRegistrationId")
|
|
||||||
.HasName("pk_internship_registration");
|
|
||||||
|
|
||||||
b1.ToTable("internship_registration");
|
|
||||||
|
|
||||||
b1.WithOwner()
|
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
|
||||||
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("AvailableInternshipTypes")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_edition_internship_type_editions_edition_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "InternshipType")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipTypeId")
|
|
||||||
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("AvailableSubjects")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_edition_subject_editions_edition_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipSubjectId")
|
|
||||||
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "Registration")
|
|
||||||
.WithMany("Subjects")
|
|
||||||
.HasForeignKey("InternshipRegistrationId")
|
|
||||||
.HasConstraintName("fk_program_subject_internship_registration_internship_registrat")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("InternshipSubjectId")
|
|
||||||
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
|
||||||
.WithMany("ReportSchema")
|
|
||||||
.HasForeignKey("EditionId")
|
|
||||||
.HasConstraintName("fk_report_field_edition_editions_edition_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReportFieldId")
|
|
||||||
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Repository.Migrations
|
|
||||||
{
|
|
||||||
public partial class Insurance : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "require_insurance",
|
|
||||||
table: "internship_types",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "require_insurance",
|
|
||||||
table: "internship_types");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user