Compare commits

..

No commits in common. "master" and "MoreEndpoints" have entirely different histories.

75 changed files with 1117 additions and 5088 deletions
.build
PostmanTestRequest
README.MDglobal.json
src
InternshipSystem.Api
InternshipSystem.Core
InternshipSystem.Repository
test
InternshipSystem.Api.Test
InternshipSystem.Core.Tests

View File

@ -1,4 +1,9 @@
BUILD_PATH=$1
cd $BUILD_PATH/src || exit 1
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
cd $BUILD_PATH/.docker || exit 1
docker-compose up -d --build --force-recreate

View File

@ -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": []
}
]
}

View File

@ -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
View File

@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.301"
}
}

View File

@ -3,7 +3,6 @@ using AutoMapper;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Result;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -19,27 +18,12 @@ namespace InternshipSystem.Api
.ForMember(
result => result.Status,
opt => opt.MapFrom(edition => edition.IsOpen ? "Open" : "Archival"));
CreateMap<Edition, EditionManagementResult>();
CreateMap<Edition, EditionDetailsResult>();
CreateMap<Edition, EditionConfigurationResult>();
CreateMap<InternshipSubject, InternshipSubject>();
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>();
CreateMap<EditionSubject, InternshipSubject>().IncludeMembers(es => es.Subject);
}
}
}

View File

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

View File

@ -1,9 +1,12 @@
using System;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using FluentValidation;
using InternshipSystem.Api.Options;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Repository;
@ -11,6 +14,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Serilog;
namespace InternshipSystem.Api.Controllers
{
@ -36,8 +40,8 @@ namespace InternshipSystem.Api.Controllers
}
[HttpPost("login")]
public async Task<ActionResult> Authenticate([FromBody] string code, CancellationToken cancellationToken)
[HttpGet("login")]
public async Task<ActionResult> Authenticate(string code, CancellationToken cancellationToken)
{
var token = await _loginClient.GetCasTokenAsync(code, cancellationToken);
@ -80,7 +84,7 @@ namespace InternshipSystem.Api.Controllers
return Ok(_tokenService.generateToken(identity));
}
[HttpPost("loginEdition")]
[HttpGet("loginEdition")]
[Authorize]
public async Task<ActionResult> LoginIntoEdition([FromBody] Guid editionId, [FromServices] User user, CancellationToken token)
{

View File

@ -4,7 +4,6 @@ using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Queries.SearchQuery;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
@ -36,11 +35,9 @@ namespace InternshipSystem.Api.Controllers
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[Authorize]
public async Task<ActionResult<IReadOnlyCollection<Company>>> SearchByNameAsync([FromQuery] CompanySearchQuery searchQuery, [FromServices] User user, CancellationToken cancellationToken) =>
public async Task<ActionResult<IReadOnlyCollection<Company>>> SearchByNameAsync([FromQuery] CompanySearchQuery searchQuery, CancellationToken cancellationToken) =>
await Context.Companies
.Where(c => c.Name.ToLower().Contains(searchQuery.Name.ToLower()))
.Where(c => c.Provider == 0 || c.Provider == user.PersonNumber)
.OrderBy(o => o.Name)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
@ -57,8 +54,7 @@ namespace InternshipSystem.Api.Controllers
[HttpGet("{companyId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[Authorize]
public async Task<ActionResult<IReadOnlyCollection<BranchOffice>>> SearchBranchesByAddress([FromQuery] BranchOfficeSearchQuery searchQuery, long companyId, [FromServices] User user, CancellationToken token)
public async Task<ActionResult<IReadOnlyCollection<BranchOffice>>> SearchBranchesByAddress([FromQuery] BranchOfficeSearchQuery searchQuery, long companyId, CancellationToken token)
{
var company = await Context.Companies.Where(c => c.Id == companyId).FirstAsync(token);
@ -66,7 +62,6 @@ namespace InternshipSystem.Api.Controllers
.Collection(c => c.Branches)
.Query()
.Where(office => office.Address.City.ToLower().Contains(searchQuery.City.ToLower()))
.Where(office => office.Provider == 0 || office.Provider == user.PersonNumber)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(token);
@ -78,16 +73,14 @@ namespace InternshipSystem.Api.Controllers
/// <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)
public async Task<ActionResult> UpdateCompany([FromBody] CompanyForm companyForm, CancellationToken cancellationToken)
{
var validator = new CompanyForm.Validator();
var validationResult = await validator.ValidateAsync(companyForm, cancellationToken);
@ -99,24 +92,30 @@ namespace InternshipSystem.Api.Controllers
if (companyForm.Id.HasValue)
{
var companyToUpdate = await Context.Companies.FindAsync(companyForm.Id.Value);
var companyToUpdate = await Context.Companies.FindAsync(companyForm.Id);
if (companyToUpdate == null)
if (companyToUpdate != null)
{
return NotFound();
companyToUpdate.Name = IsNullOrEmpty(companyForm.Name) ? companyToUpdate.Name : companyForm.Name;
companyToUpdate.Nip = IsNullOrEmpty(companyForm.Nip) ? companyToUpdate.Nip : companyForm.Nip;
}
else
{
return NotFound($"Company with id: {companyForm.Id} does not exist");
}
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);
var newCompany = new Company
{
Name = companyForm.Name,
Nip = companyForm.Nip,
};
await Context.Companies.AddAsync(newCompany, cancellationToken);
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Company updated successfully");
}
/// <summary>
@ -125,29 +124,28 @@ namespace InternshipSystem.Api.Controllers
/// <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);
.FirstOrDefaultAsync(c => c.Id.Equals(companyId), cancellationToken: cancellationToken);
if (companyToDelete == null)
{
return NotFound();
return NotFound($"Company with id: {companyId} does not exist");
}
Context.Companies.Attach(companyToDelete);
Context.Companies.Remove(companyToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Company with id: {companyId} deleted successfully");
}
/// <summary>
@ -156,14 +154,12 @@ namespace InternshipSystem.Api.Controllers
/// <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="400">Branch office was malformed/response>
/// <response code="404">Company or branch office not found</response>
/// <returns></returns>
[HttpPut("{companyId}/branchOffices")]
[HttpPut("branchOffice/{companyId}")]
[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)
@ -178,20 +174,20 @@ namespace InternshipSystem.Api.Controllers
var company = await Context.Companies
.Include(c => c.Branches)
.FirstOrDefaultAsync(c => c.Id == companyId, cancellationToken);
.FirstOrDefaultAsync(c => c.Id.Equals(companyId), cancellationToken: cancellationToken);
if (company == null)
{
return NotFound();
return NotFound($"Company with id: {companyId} does not exist");
}
if (branchOfficeForm.Id.HasValue)
{
var branchOffice = company.Branches.First(b => b.Id == branchOfficeForm.Id);
var branchOffice = company.Branches.Find(b => b.Id.Equals(branchOfficeForm.Id.Value));
if (branchOffice == null)
{
return NotFound();
return NotFound($"Branch office with id: {branchOfficeForm.Id} does not exist");
}
branchOffice.Address.Country = IsNullOrEmpty(branchOfficeForm.Country) ? branchOffice.Address.Country : branchOfficeForm.Country;
@ -217,7 +213,7 @@ namespace InternshipSystem.Api.Controllers
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Branch office updated successfully");
}
/// <summary>
@ -226,31 +222,31 @@ namespace InternshipSystem.Api.Controllers
/// <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}")]
/// <returns></returns>
[HttpDelete("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)
public async Task<ActionResult> DeleteBranch(long branchOfficeId, CancellationToken cancellationToken)
{
var company =
await Context.Companies
.Include(c => c.Branches)
.Where(c => c.Id == companyId)
.FirstOrDefaultAsync(cancellationToken);
.Where(c => c.Branches.Any(b => b.Id.Equals(branchOfficeId)))
.FirstOrDefaultAsync(cancellationToken: cancellationToken);
if (company == null)
{
return NotFound();
return NotFound($"Branch office with id: {branchOfficeId} does not exist");
}
var branchOffice = company.Branches.RemoveAll(b => b.Id == branchOfficeId);
var branchOffice = company.Branches.Find(b => b.Id.Equals(branchOfficeId));
company.Branches.Remove(branchOffice);
await Context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Branch office with id: {branchOfficeId} deleted successfully");
}
}
}

View File

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

View File

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

View File

@ -1,18 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.Service;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using InternshipSystem.Api.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
@ -20,19 +13,18 @@ namespace InternshipSystem.Api.Controllers
[Route("document")]
public class DocumentsController : ControllerBase
{
private readonly InternshipDbContext _context;
private readonly FileValidator _fileValidator;
private readonly IInternshipService _internshipService;
public DocumentsController(InternshipDbContext context, FileValidator fileValidator)
public DocumentsController(IInternshipService internshipService)
{
_context = context;
_fileValidator = fileValidator;
_internshipService = internshipService;
}
/// <summary>
/// Fill out required document,
/// </summary>
/// <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="400">If the provided query was malformed</response>
/// <response code="404">Id doesn't match any required document</response>
@ -43,139 +35,18 @@ namespace InternshipSystem.Api.Controllers
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> AddDocumentToInternship(
[FromBody] DocumentPublishRequest documentRequest,
[FromServices] User user,
CancellationToken cancellationToken)
public async Task<ActionResult> AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest,
[FromServices] User user, CancellationToken cancellationToken)
{
var validator = new DocumentPublishRequest.Validator();
var result = await validator.ValidateAsync(documentRequest, cancellationToken);
if (!result.IsValid)
{
return BadRequest(result.ToString());
}
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);
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);
var validationResult = await validator.ValidateAsync(documentRequest, cancellationToken);
if (!_fileValidator.IsValidFile(memoryStream.ToArray()))
if (!validationResult.IsValid)
{
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 BadRequest(validationResult.ToString());
}
return Ok(scan);
return await _internshipService.AddDocumentToInternship(documentRequest, user, cancellationToken);
}
}
}

View File

@ -38,7 +38,7 @@ namespace InternshipSystem.Api.Controllers
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult<IEnumerable<EditionResult>>> GetAvailableEditions([FromServices] User user, CancellationToken token)
public async Task<ActionResult<IList<EditionResult>>> GetAvailableEditions([FromServices] User user, CancellationToken token)
{
var editions =
await Context.Editions
@ -57,52 +57,23 @@ namespace InternshipSystem.Api.Controllers
}
/// <summary>
/// Get accessible editions
/// </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
/// Get edition's configuration
/// </summary>
/// <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="404">Specified edition doesn't exist</response>
/// <returns></returns>
[HttpGet("current")]
[HttpGet("{id}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration([FromServices] User user, CancellationToken token)
[Authorize]
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration(Guid id, CancellationToken token)
{
var edition =
await Context.Editions
.Include(e => e.AvailableSubjects)
.Include(e => e.ReportSchema)
.ThenInclude(e => e.Field)
.Include(e => e.Course)
.Where(e => e.Id == user.EditionId)
.Where(e => e.Id.Equals(id))
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
.FirstOrDefaultAsync(token);

View File

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

View File

@ -1,13 +1,11 @@
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
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
{
@ -41,9 +39,9 @@ namespace InternshipSystem.Api.Controllers
};
var response = await _client.SendAsync(request, cancellationToken);
var content = await response.Content.ReadAsStringAsync();
await using var stream = await response.Content.ReadAsStreamAsync();
var value = JsonConvert.DeserializeObject<Dictionary<string, object>>(content);
var value = await JsonSerializer.DeserializeAsync<Dictionary<string, object>>(stream);
return value["access_token"].ToString();
}
@ -62,10 +60,15 @@ namespace InternshipSystem.Api.Controllers
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
var response = await _client.SendAsync(request, cancellationToken);
var content = await response.Content.ReadAsStringAsync();
await using var stream = await response.Content.ReadAsStreamAsync();
var result = await JsonSerializer.DeserializeAsync<CasUserProfile>(
stream,
new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
var result = JsonConvert.DeserializeObject<CasUserProfile>(content);
return result.Attributes;
}
}

View File

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

View File

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

View File

@ -1,32 +1,33 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Commands;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.UseCases;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using InternshipSystem.Api.Services;
using InternshipSystem.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("internshipRegistration")]
public class InternshipRegistrationController : ControllerBase
{
private readonly IInternshipService _internshipService;
private readonly InternshipDbContext _context;
public InternshipRegistrationController(InternshipDbContext dbContext)
{
_context = dbContext;
}
public InternshipRegistrationController(IInternshipService internshipService, InternshipDbContext context)
{
_internshipService = internshipService;
_context = context;
}
/// <summary>
/// Validate and add filled internship registration form
/// </summary>
/// <param name="updateRegistration">Internship registration data</param>
/// <response code="200">If registration form was successfully added</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>
@ -35,51 +36,46 @@ namespace InternshipSystem.Api.Controllers
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> SubmitRegistrationForm(
[FromBody] UpdateRegistrationForm registrationCommand,
[FromServices] User user,
CancellationToken cancellationToken)
public async Task<ActionResult> SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery,
[FromServices] User user, CancellationToken cancellationToken)
{
var validator = new RegistrationFormQuery.Validator();
var validationResult = await validator.ValidateAsync(registrationQuery, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
return await _internshipService.SubmitRegistration(registrationQuery, user, cancellationToken);
}
[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
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(t => t.InternshipType)
.Include(e => e.AvailableSubjects)
.ThenInclude(t => t.Subject)
.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship =
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);
.FindAsync(user.EditionId);
await _context.SaveChangesAsync(cancellationToken);
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.InternshipProgram)
.Include(i => i.Report)
.Include(i => i.Approvals)
.Include(i => i.Documentation)
.SingleAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
return new JsonResult(new {Status = status, Errors = result});
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
internship.Edition = null;
return Ok(internship);
}
}
}

View File

@ -25,20 +25,19 @@ namespace InternshipSystem.Api.Controllers
}
/// <summary>
/// Get internship types available for current edition
/// Get static page
/// </summary>
/// <returns>List of internship types for current edition</returns>
[HttpGet("current")]
/// <returns>List of internship types for edition</returns>
[HttpGet("forCurrentEdition")]
[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)
public async Task<ActionResult<IList<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);
@ -47,16 +46,9 @@ namespace InternshipSystem.Api.Controllers
return NotFound();
}
return Ok(edition.AvailableInternshipTypes.Select(e => e.InternshipType));
return Ok(edition.AvailableInternshipTypes);
}
/// <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)]
@ -67,41 +59,28 @@ namespace InternshipSystem.Api.Controllers
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)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult<IEnumerable<InternshipType>>> SearchInternshipTypes([FromQuery] InternshipTypeSearchQuery searchQuery, CancellationToken cancellationToken)
public async Task<ActionResult<IList<InternshipType>>> SearchInternshipTypes([FromBody] 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)
.Where(t => string.IsNullOrEmpty(searchQuery.Type) || t.Type.Contains(searchQuery.Type))
.OrderBy(t => t.Type)
.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)
public async Task<ActionResult> UpdateInternshipType([FromBody] InternshipTypeFrom internshipTypeFrom, CancellationToken cancellationToken)
{
var validator = new InternshipTypeFrom.Validator();
var validationResult = await validator.ValidateAsync(internshipTypeFrom, cancellationToken);
@ -120,8 +99,7 @@ namespace InternshipSystem.Api.Controllers
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.Type = string.IsNullOrEmpty(internshipTypeFrom.Type) ? internshipType.Type : internshipTypeFrom.Type;
internshipType.Description = string.IsNullOrEmpty(internshipTypeFrom.Description) ? internshipType.Description : internshipTypeFrom.Description;
internshipType.DescriptionEng = string.IsNullOrEmpty(internshipTypeFrom.DescriptionEng) ? internshipType.DescriptionEng : internshipTypeFrom.DescriptionEng;
}
@ -129,8 +107,7 @@ namespace InternshipSystem.Api.Controllers
{
var newInternshipType = new InternshipType
{
Label = internshipTypeFrom.Label,
LabelEng = internshipTypeFrom.LabelEng,
Type = internshipTypeFrom.Type,
Description = internshipTypeFrom.Description,
DescriptionEng = internshipTypeFrom.DescriptionEng,
};
@ -139,17 +116,12 @@ namespace InternshipSystem.Api.Controllers
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Internship type updated successfully");
}
/// <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.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
@ -163,6 +135,7 @@ namespace InternshipSystem.Api.Controllers
return NotFound($"Internship type with id: {internshipTypeId} does not exist");
}
Context.InternshipTypes.Attach(internshipTypeToDelete);
Context.InternshipTypes.Remove(internshipTypeToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok($"Internship type with id: {internshipTypeId} deleted successfully");

View File

@ -38,7 +38,6 @@ namespace InternshipSystem.Api.Controllers
{
var edition = await _context.Editions
.Include(e => e.Internships)
.ThenInclude(i => i.Student)
.FirstOrDefaultAsync(e => e.Id.Equals(registrationCode), cancellationToken: token);
if (edition == null)
@ -48,15 +47,8 @@ namespace InternshipSystem.Api.Controllers
var student = await _context.Students.FindAsync(user.PersonNumber);
try
{
edition.RegisterInternship(student);
await _context.SaveChangesAsync(token);
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
edition.RegisterInternship(student);
await _context.SaveChangesAsync(token);
return Ok();
}

View File

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

View File

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

View File

@ -21,12 +21,11 @@ namespace InternshipSystem.Api.Controllers
Context = context;
}
private InternshipDbContext Context { get; }
/// <summary>
/// Get all static pages, only available for coordinator
/// Get all static pages
/// </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) =>
@ -34,12 +33,10 @@ namespace InternshipSystem.Api.Controllers
.ToListAsync(cancellationToken);
/// <summary>
/// Get static page, only available for coordinator
/// Get static page
/// </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)]
@ -58,13 +55,6 @@ namespace InternshipSystem.Api.Controllers
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)]
@ -121,7 +111,7 @@ namespace InternshipSystem.Api.Controllers
{
AccessName = staticPageForm.AccessName.ToLower().Trim(),
Title = staticPageForm.Title,
TitleEng = staticPageForm.TitleEng,
TitleEng = staticPageForm.Title,
Content = staticPageForm.Content,
ContentEng = staticPageForm.ContentEng,
};
@ -132,13 +122,8 @@ namespace InternshipSystem.Api.Controllers
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)]
@ -155,6 +140,7 @@ namespace InternshipSystem.Api.Controllers
return NotFound($"Static page with access name: {accessName} does not exist");
}
Context.StaticPages.Attach(pageToDelete);
Context.StaticPages.Remove(pageToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok($"Static page with access name: {accessName} deleted successfully");

View File

@ -7,7 +7,6 @@ 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;
@ -24,29 +23,14 @@ namespace InternshipSystem.Api.Controllers
_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)
{
@ -61,35 +45,17 @@ namespace InternshipSystem.Api.Controllers
await _context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Student updated successfully");
}
/// <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) =>
public async Task<ActionResult<IReadOnlyCollection<Student>>> GetStudents([FromBody] 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()))
@ -98,20 +64,10 @@ namespace InternshipSystem.Api.Controllers
.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)]
[HttpPut]
[Authorize]
public async Task<ActionResult> UpdateStudentData(long studentId, [FromBody] StudentForm studentNewData, CancellationToken cancellationToken)
public async Task<ActionResult> UpdateStudentData([FromBody] StudentForm studentNewData, CancellationToken cancellationToken)
{
var validator = new StudentForm.Validator();
var validationResult = await validator.ValidateAsync(studentNewData, cancellationToken);
@ -121,11 +77,11 @@ namespace InternshipSystem.Api.Controllers
return BadRequest(validationResult.ToString());
}
var currentStudent = await _context.Students.FindAsync(studentId);
var currentStudent = await _context.Students.FindAsync(studentNewData.Id);
if (currentStudent == null)
{
return NotFound();
return NotFound($"Student with id: {studentNewData.Id} does not exist");
}
currentStudent.AlbumNumber = studentNewData.AlbumNumber ?? currentStudent.AlbumNumber;
@ -137,7 +93,7 @@ namespace InternshipSystem.Api.Controllers
await _context.SaveChangesAsync(cancellationToken);
return Ok();
return Ok($"Student updated successfully");
}
}
}

View File

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

View File

@ -12,13 +12,11 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="FluentValidation" Version="9.1.2" />
<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="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.2" />
<PackageReference Include="IdentityServer4" Version="3.1.4" />
</ItemGroup>

View File

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

View File

@ -1,16 +1,22 @@
using FluentValidation;
using InternshipSystem.Core.ValueObject;
using Microsoft.AspNetCore.Http;
namespace InternshipSystem.Api.Queries
{
public class DocumentPublishRequest
{
public long? Id { get; set; }
public string Description { get; set; }
public byte[] Scan { get; set; }
public DocumentType Type { get; set; }
public class Validator : AbstractValidator<DocumentPublishRequest>
{
public Validator()
{
RuleFor(document => document.Scan).NotEmpty();
RuleFor(document => document.Type).NotEmpty();
}
}
}
}

View File

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

View File

@ -5,8 +5,7 @@ namespace InternshipSystem.Api.Queries
public class InternshipTypeFrom
{
public long? Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
@ -16,10 +15,12 @@ namespace InternshipSystem.Api.Queries
{
RuleFor(t => t.Id).NotNull()
.When(t =>
string.IsNullOrEmpty(t.Label) || string.IsNullOrEmpty(t.LabelEng));
RuleFor(t => t.Label).NotEmpty()
string.IsNullOrEmpty(t.Description) || string.IsNullOrEmpty(t.Type) || string.IsNullOrEmpty(t.DescriptionEng));
RuleFor(t => t.Type).NotEmpty()
.When(t => !t.Id.HasValue);
RuleFor(t => t.LabelEng).NotEmpty()
RuleFor(t => t.Description).NotEmpty()
.When(t => !t.Id.HasValue);
RuleFor(t => t.DescriptionEng).NotEmpty()
.When(t => !t.Id.HasValue);
}
}

View File

@ -1,7 +0,0 @@
namespace InternshipSystem.Api.Queries.SearchQuery
{
public class EditionSearchQuery : SearchQuery
{
public long? Course { get; set; }
}
}

View File

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

View File

@ -4,7 +4,6 @@ namespace InternshipSystem.Api.Controllers
{
public class InternshipTypeSearchQuery : SearchQuery
{
public string Label { get; set; } = "";
public string LabelEng { get; set; } = "";
public string Type { get; set; } = "";
}
}

View File

@ -1,9 +0,0 @@
namespace InternshipSystem.Api.Queries.SearchQuery
{
public enum SortOrder
{
Asc,
Desc,
None
}
}

View File

@ -4,6 +4,7 @@ namespace InternshipSystem.Api.Queries
{
public class StudentForm
{
public long Id { get; set; }
public int? AlbumNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
@ -15,6 +16,7 @@ namespace InternshipSystem.Api.Queries
{
public Validator()
{
RuleFor(c => c.Id).NotNull();
}
}
}

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using InternshipSystem.Api.Converters;
using Newtonsoft.Json;
namespace InternshipSystem.Api.Controllers
{
@ -9,12 +7,8 @@ namespace InternshipSystem.Api.Controllers
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; }
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -10,7 +9,6 @@ namespace InternshipSystem.Api.Result
public class EditionConfigurationResult
{
public List<InternshipSubject> AvailableSubjects { get; set; }
public List<ReportField> ReportSchema { get; set; }
public Course Course { get; set; }
public DateTime EditionStart { get; set; }
public DateTime EditionFinish { get; set; }

View File

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

View File

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

View File

@ -2,7 +2,7 @@
namespace InternshipSystem.Api.Result
{
public class EditionResult
public struct EditionResult
{
public Guid Id { get; set; }
public DateTime EditionStart { get; set; }

View File

@ -3,6 +3,5 @@
public static class Policies
{
public const string RegisteredOnly = "RegisteredForEditionOnly";
public const string IsOverseer = "IsOverseer";
}
}

View File

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

View File

@ -0,0 +1,17 @@
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using Microsoft.AspNetCore.Mvc;
namespace InternshipSystem.Api.Services
{
public interface IInternshipService
{
Task<ActionResult> SubmitRegistration(RegistrationFormQuery registrationQuery, User user,
CancellationToken cancellationToken);
Task<ActionResult> AddDocumentToInternship(DocumentPublishRequest documentRequest, User user,
CancellationToken cancellationToken);
}
}

View File

@ -0,0 +1,121 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
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, User user,
CancellationToken cancellationToken)
{
var edition = await _context.Editions
.Include(e => e.AvailableInternshipTypes)
.FirstOrDefaultAsync(e => e.Id.Equals(user.EditionId), cancellationToken: cancellationToken);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.InternshipRegistration)
.Include(i => i.InternshipRegistration.Company)
.Include(i => i.InternshipRegistration.BranchAddress)
.SingleAsync(i => i.Student.Id == user.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 != null && edition.IsInternshipTypeAllowed(registrationQuery.Type))
{
return new BadRequestObjectResult("Edition doesn't have this type of employment in available employments type");
}
internshipRegistration.Type = registrationQuery.Type != null ? edition.AvailableInternshipTypes.Find(ai => ai.Id.Equals(registrationQuery.Type.Id)) : internshipRegistration.Type;
await _context.SaveChangesAsync(cancellationToken);
return new OkResult();
}
public async Task<ActionResult> AddDocumentToInternship(DocumentPublishRequest documentRequest, 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.Documentation)
.SingleAsync(i => i.Student.Id == user.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();
}
}
}

View File

@ -7,7 +7,7 @@ using InternshipSystem.Api.Extensions;
using InternshipSystem.Api.ModelBinders;
using InternshipSystem.Api.Options;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.Service;
using InternshipSystem.Api.Services;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@ -16,8 +16,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace InternshipSystem.Api
{
@ -38,8 +36,6 @@ namespace InternshipSystem.Api
.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>();
@ -47,10 +43,10 @@ namespace InternshipSystem.Api
.AddDbContext<InternshipDbContext>(o =>
o.UseNpgsql(Configuration.GetConnectionString("InternshipDatabase")))
.AddScoped<DatabaseFiller>()
.AddScoped<FileValidator>()
.AddScoped<IInternshipService, InternshipService>()
.AddScoped<JwtTokenService>()
.AddAutoMapper(cfg => cfg.AddProfile<ApiProfile>());
services
.AddSwaggerGen(options =>
{
@ -59,13 +55,7 @@ namespace InternshipSystem.Api
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
options.IncludeXmlComments(xmlPath);
})
.AddSwaggerGenNewtonsoftSupport()
.AddControllers(o => { o.ModelBinderProviders.Insert(0, new UserBinderProvider()); })
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
.AddControllers(o => { o.ModelBinderProviders.Insert(0, new UserBinderProvider()); });
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

View File

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

View File

@ -0,0 +1,33 @@
using System;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core.Commands
{
public class UpdateRegistrationForm
{
public UpdateCompany? Company { get; set; }
public DateTime? Start { get; set; }
public DateTime? End { get; set; }
public InternshipType? Type { 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 IsUpdate => Id.HasValue;
}
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; }
}
}

View File

@ -1,48 +1,31 @@
using FluentValidation;
using FluentValidation.Validators;
namespace InternshipSystem.Core
namespace InternshipSystem.Core
{
public class BranchOffice
{
public BranchOffice()
{
}
private BranchOffice(BranchAddress address, long provider)
private BranchOffice(BranchAddress address)
{
Address = address;
Provider = provider;
}
public long Id { 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, long provider = 0)
public static BranchOffice CreateBranch(string country, string city, string postalCode, string street, string building)
{
var address = new BranchAddress
{
Building = building,
Building = building,
City = city,
Country = country,
Street = street,
PostalCode = postalCode
};
return new BranchOffice(address, provider);
}
public class Validator : AbstractValidator<BranchOffice>
{
public Validator()
{
RuleFor(x => x.Address)
.SetValidator(new BranchAddress.Validator());
}
return new BranchOffice(address);
}
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using FluentValidation.Validators;
using InternshipSystem.Core.Commands;
namespace InternshipSystem.Core
{
@ -12,33 +11,25 @@ namespace InternshipSystem.Core
public string Name { get; set; }
public List<BranchOffice> Branches { get; set; }
public long Provider { get; set; }
public static Company CreateCompany(string nip, string name, long provider = 0) =>
public static Company CreateCompany(string nip, string name) =>
new Company
{
Nip = nip,
Name = name,
Provider = provider,
Branches = new List<BranchOffice>()
Name = name
};
public void AddBranchAddress(BranchAddress branch)
{
}
public void AddBranchOffice(BranchOffice createBranch)
{
Branches.Add(createBranch);
}
public class Validator : AbstractValidator<Company>
public static Company CreateCompany(UpdateCompany updateCompany)
{
public Validator()
{
RuleFor(x => x.Nip)
.NotEmpty()
.WithMessage("error.company.nip.empty");
RuleFor(x => x.Name)
.NotEmpty()
.WithMessage("error.company.name.empty");
}
throw new NotImplementedException();
}
}
}

View File

@ -1,24 +1,8 @@
using System.Collections.Generic;
namespace InternshipSystem.Core.Entity
namespace InternshipSystem.Core
{
public class Course
{
public long Id { 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;
}
}
}

View File

@ -6,19 +6,9 @@ namespace InternshipSystem.Core
{
public long Id { get; set; }
public string Description { get; set; }
public DocumentScan Scan { get; set; }
public byte[] Scan { get; set; }
public DocumentType Type { get; set; }
public DocumentState State { get; set; }
public string ChangeStateComment { 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; }
public string RejectionReason { get; set; }
}
}

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -15,112 +13,33 @@ namespace InternshipSystem.Core
public DateTime ReportingStart { get; set; }
public Course Course { get; set; }
public List<Internship> Internships { get; set; }
public InternshipType AllowedInternshipTypes { get; set; }
public List<EditionSubject> AvailableSubjects { get; set; }
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
public List<ReportFieldEdition> ReportSchema { get; set; }
public List<InternshipType> AvailableInternshipTypes { get; set; }
public bool IsOpen => EditionFinish < DateTime.Today;
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course,
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)
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
{
return new Edition
{
EditionStart = start,
EditionFinish = end,
ReportingStart = reportingStart,
Course = course,
AvailableSubjects = new List<EditionSubject>(),
AvailableInternshipTypes = new List<EditionInternshipType>(),
ReportSchema = new List<ReportFieldEdition>()
ReportingStart = reportingStart
};
}
public void UpdateEdition(DateTime? start, DateTime? end, DateTime? reportingStart, Course course,
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
public bool IsInternshipTypeAllowed(InternshipType registrationQueryType)
{
EditionStart = start ?? EditionStart;
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();
}
return AvailableInternshipTypes.Contains(registrationQueryType);
}
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);
Internships.Add(internship);
}
@ -128,17 +47,5 @@ namespace InternshipSystem.Core
{
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;
}
}

View File

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

View File

@ -1,21 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using InternshipSystem.Core.Commands;
using InternshipSystem.Core.ValueObject;
namespace InternshipSystem.Core.Entity.Internship
namespace InternshipSystem.Core
{
public class Internship
{
public long Id { get; set; }
public Student Student { get; set; }
public InternshipRegistration InternshipRegistration { get; set; }
public InternshipProgram InternshipProgram { get; set; }
public Report Report { get; set; }
public List<Document> Approvals { get; set; }
public List<Document> Documentation { get; set; }
public Edition Edition { get; set; }
public float? Grade { 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)
{
@ -24,82 +44,45 @@ namespace InternshipSystem.Core.Entity.Internship
internship.Student = student;
internship.InternshipRegistration = InternshipRegistration.Create();
internship.InternshipProgram = InternshipProgram.Create();
internship.Report = Report.Create();
internship.Approvals = new List<Document>();
internship.Documentation = new List<Document>();
if (student.Semester != 6)
{
internship.AddNewDocument("", DocumentType.OutsideSemesterApproval);
}
return internship;
}
public void AddNewDocument(string description, DocumentType type)
public void UpdateInternshipRegistration(UpdateRegistrationForm updateRegistration)
{
if (type != DocumentType.Other && Documentation.Any(d => d.Type == type))
var start = updateRegistration.Start ?? InternshipRegistration.Start;
var end = updateRegistration.End ?? InternshipRegistration.End;
if (!Edition.IsDateDuringEdition(start, end))
{
return;
throw new ArgumentOutOfRangeException(nameof(InternshipRegistration.Start) + nameof(InternshipRegistration.End),"Date outside of edition boundaries");
}
var internshipType = updateRegistration.Type ?? InternshipRegistration.Type;
if (!Edition.IsInternshipTypeAllowed(internshipType))
{
throw new ArgumentException("Internship type not allowed for this edition", nameof(updateRegistration.Type));
}
var company = InternshipRegistration.Company;
if (company == null)
{
if (!updateRegistration.Company.HasValue)
{
throw new ArgumentException("Company");
}
company = Company.CreateCompany(updateRegistration.Company.Value);
}
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");
}
InternshipRegistration.Update(start, end, internshipType);
}
}
}

View File

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

View File

@ -1,82 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using InternshipSystem.Core.UglyOrmArtifacts;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core.Entity.Internship
namespace InternshipSystem.Core
{
public class InternshipRegistration
{
public long Id { get; set; }
public Company Company { get; set; }
public BranchOffice BranchAddress { get; set; }
public DateTime SubmissionDate { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public Mentor Mentor { get; set; }
public List<ProgramSubject> Subjects { get; set; }
public InternshipType Type { get; set; }
public int DeclaredHours { get; set; }
public DocumentState State { get; set; }
public string ChangeStateComment { get; set; }
public static InternshipRegistration Create()
{
return new InternshipRegistration();
}
public (DocumentState State, IEnumerable<ErrorDescription>) ValidateStatus(Edition edition)
public void Update(DateTime start, DateTime end, InternshipType internshipType)
{
var validator = new Validator(edition);
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());
Start = start;
End = end;
Type = internshipType;
}
public void UpdateCompany(Company newCompany)
{
Company = newCompany;
}
public class Validator : AbstractValidator<InternshipRegistration>
public void UpdateBranch(BranchOffice branch)
{
public Validator(Edition edition)
{
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");
}
BranchAddress = branch;
}
}
public class ErrorDescription
{
public string Key { get; set; }
public Dictionary<string, object> Parameters { get; set; }
}
}

View File

@ -3,11 +3,8 @@
public class InternshipType
{
public long Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public bool RequireDeansApproval { get; set; }
public bool RequireInsurance { get; set; }
}
}

View File

@ -6,17 +6,12 @@ namespace InternshipSystem.Core
{
public long Id { 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()
{
return new Report();
}
public void UpdateReport(string reportValue)
{
Value = reportValue;
State = DocumentState.Submitted;
}
}
}

View File

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

View File

@ -5,8 +5,4 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="9.1.2" />
</ItemGroup>
</Project>

View File

@ -1,16 +0,0 @@
using System;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core.UglyOrmArtifacts
{
public class EditionInternshipType
{
public Edition Edition { get; set; }
public Guid EditionId { get; set; }
public InternshipType InternshipType { get; set; }
public long InternshipTypeId { get; set; }
}
}

View File

@ -4,8 +4,8 @@ namespace InternshipSystem.Core.UglyOrmArtifacts
{
public class ProgramSubject
{
public long InternshipRegistrationId { get; set; }
public InternshipRegistration Registration { get; set; }
public long InternshipProgramId { get; set; }
public InternshipProgram Program { get; set; }
public long InternshipSubjectId { get; set; }
public InternshipSubject Subject { get; set; }
}

View File

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

View File

@ -1,7 +1,4 @@
using FluentValidation;
using FluentValidation.Validators;
namespace InternshipSystem.Core
namespace InternshipSystem.Core
{
public class BranchAddress
{
@ -10,27 +7,5 @@ namespace InternshipSystem.Core
public string City { get; set; }
public string PostalCode { 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");
}
}
}
}

View File

@ -3,7 +3,7 @@
public enum DocumentState
{
// Oczekujaca
Draft,
NotSubmitted,
// Oczekuje na akceptacje
Submitted,
// Zaakceptowana

View File

@ -3,11 +3,7 @@
public enum DocumentType
{
IppScan,
OutsideTermApproval,
InternshipTypeApproval,
OutsideSemesterApproval,
NnwInsurance,
InternshipEvaluation,
Other
DeanConsent,
NnwIsurance
}
}

View File

@ -1,6 +1,4 @@
using FluentValidation;
namespace InternshipSystem.Core
namespace InternshipSystem.Core
{
public class Mentor
{
@ -8,33 +6,5 @@ namespace InternshipSystem.Core
public string LastName { get; set; }
public string Email { get; set; }
public string 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");
}
}
}
}

View File

@ -3,10 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
using InternshipSystem.Core.ValueObject;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Repository
@ -34,6 +32,7 @@ namespace InternshipSystem.Repository
{
new Company
{
Id = 1,
Name = "Intel",
// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
Nip = "9570752316",
@ -76,6 +75,7 @@ namespace InternshipSystem.Repository
},
new Company
{
Id = 2,
Name = "Asseco Poland",
// SiteAddress = new Uri("http://pl.asseco.com"),
Nip = "5842068320",
@ -116,52 +116,51 @@ namespace InternshipSystem.Repository
{
new InternshipType
{
Label = "Umowa o organizację praktyki",
LabelEng = "Internship agreement",
Type = "FreeInternship",
Description = "Praktyka bezpłatna",
DescriptionEng = "Free internship",
RequireInsurance = true
},
new InternshipType
{
Label = "Umowa o praktykę absolwencką",
LabelEng = "Graduate internship agreement",
Type = "GraduateInternship",
Description = "Praktyka absolwencka",
DescriptionEng = "Graduate internship",
},
new InternshipType
{
Label = "Umowa o staż bezpłatny",
LabelEng = "Free apprenticeship agreement",
RequireInsurance = true
Type = "FreeApprenticeship",
Description = "Praktyka bezpłatna",
DescriptionEng = "Free apprenticeship",
},
new InternshipType
{
Label = "Umowa o staż płatny",
LabelEng = "Paid apprenticeship agreement",
Description = "np. staż przemysłowy",
DescriptionEng = "e.g. industrial apprenticeship",
Type = "PaidApprenticeship",
Description = "np. przemysłowy",
DescriptionEng = "Paid apprenticeship",
},
new InternshipType
{
Label = "Praktyka Zagraniczna",
LabelEng = "Foreign Internship",
Description = "IAESTE, ERASMUS",
DescriptionEng = "IAESTE, ERASMUS",
Type = "ForeignInternship",
Description = "np. IAESTE, ERASMUS",
DescriptionEng = "Foreign internship",
},
new InternshipType
{
Label = "Umowa o pracę",
LabelEng = "Contract of employment",
Type = "UOP",
Description = "umowa o pracę",
DescriptionEng = "contract of employment",
},
new InternshipType
{
Label = "Umowa o dzieło (w tym B2B)",
LabelEng = "Contract work (including B2B)",
Type = "UD",
Description = "umowa o dzieło",
DescriptionEng = "contract work",
},
new InternshipType
{
Label = "Umowa zlecenia (w tym B2B)",
LabelEng = "Contract of mandate (including B2B)",
RequireDeansApproval = true
Type = "UZ",
Description = "umowa zlecenie",
DescriptionEng = "contract of mandate"
},
};
await Context.InternshipTypes.AddRangeAsync(internshipTypes);
@ -208,88 +207,16 @@ namespace InternshipSystem.Repository
Course = new Course
{
Name = "Informatyka",
NameEng = "Informatics",
},
AvailableInternshipTypes = new List<EditionInternshipType>
AvailableInternshipTypes = new List<InternshipType>
{
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"))
}
Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
Context.InternshipTypes.First(t => t.Type.Equals("UD")),
Context.InternshipTypes.First(t => t.Type.Equals("FreeInternship")),
},
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>(),
}
}
};
var edition = editions.First();
@ -298,14 +225,6 @@ namespace InternshipSystem.Repository
{
new Internship
{
Documentation = new List<Document>
{
new Document
{
Description = "doc",
Type = DocumentType.IppScan
}
},
Student = new Student
{
FirstName = "Jan",
@ -316,8 +235,7 @@ namespace InternshipSystem.Repository
InternshipRegistration = new InternshipRegistration
{
Company = Context.Companies.First(c => c.Name.Equals("Intel")),
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")),
SubmissionDate = new DateTime(2000, 6, 2),
Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
Start = new DateTime(2000, 7, 1),
End = new DateTime(2000, 8, 30),
State = DocumentState.Submitted,
@ -327,6 +245,9 @@ namespace InternshipSystem.Repository
.First(c => c.Name.Equals("Intel"))
.Branches
.First(),
},
InternshipProgram = new InternshipProgram
{
Mentor = new Mentor
{
FirstName = "Horacy",
@ -334,7 +255,7 @@ namespace InternshipSystem.Repository
Email = "howos@intel.com",
PhoneNumber = "605-555-555",
},
Subjects = new List<ProgramSubject>
ChosenSubjects = new List<ProgramSubject>
{
new ProgramSubject
{
@ -350,7 +271,6 @@ namespace InternshipSystem.Repository
}
}
},
Report = Report.Create()
},
new Internship
{
@ -364,8 +284,7 @@ namespace InternshipSystem.Repository
InternshipRegistration = new InternshipRegistration
{
Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")),
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")),
SubmissionDate = new DateTime(2000, 6, 1),
Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
Start = new DateTime(2000, 7, 1),
End = new DateTime(2000, 8, 30),
State = DocumentState.Submitted,
@ -375,6 +294,9 @@ namespace InternshipSystem.Repository
.First(c => c.Name.Equals("Asseco Poland"))
.Branches
.First(),
},
InternshipProgram = new InternshipProgram
{
Mentor = new Mentor
{
FirstName = "Henryk",
@ -382,7 +304,7 @@ namespace InternshipSystem.Repository
Email = "hepol@asseco.pl",
PhoneNumber = "555-525-545",
},
Subjects = new List<ProgramSubject>
ChosenSubjects = new List<ProgramSubject>
{
new ProgramSubject
{

View File

@ -1,8 +1,5 @@
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -15,14 +12,10 @@ namespace InternshipSystem.Repository
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 InternshipDbContext(DbContextOptions<InternshipDbContext> options)
: base(options)
{
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
@ -34,51 +27,24 @@ namespace InternshipSystem.Repository
modelBuilder.Entity<BranchOffice>()
.OwnsOne(bo => bo.Address);
modelBuilder.Entity<InternshipProgram>()
.OwnsOne(ip => ip.Mentor);
modelBuilder.Entity<InternshipRegistration>()
.OwnsOne(ir => ir.Mentor);
modelBuilder.Entity<DocumentScan>(builder =>
{
builder
.HasKey(scan => scan.DocumentId);
builder
.HasOne(s => s.Document)
.WithOne(d => d.Scan);
});
modelBuilder.Entity<ProgramSubject>(builder =>
{
builder
.HasKey(subject => new { InternshipProgramId = subject.InternshipRegistrationId, subject.InternshipSubjectId });
.HasKey(subject => new { subject.InternshipProgramId, subject.InternshipSubjectId });
builder
.HasOne(k => k.Registration)
.WithMany(model => model.Subjects)
.HasForeignKey(subject => subject.InternshipRegistrationId);
.HasOne(k => k.Program)
.WithMany(model => model.ChosenSubjects)
.HasForeignKey(subject => subject.InternshipProgramId);
builder
.HasOne(k => k.Subject)
.WithMany()
.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 =>
{
@ -95,37 +61,6 @@ namespace InternshipSystem.Repository
.WithMany()
.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");
}
}
}

View File

@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
[Migration("20210110210810_Init")]
partial class Init
[Migration("20200927114840_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -33,10 +33,6 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_branch_office");
@ -62,16 +58,30 @@ namespace InternshipSystem.Repository.Migrations
.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.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.HasKey("Id")
.HasName("pk_course");
b.ToTable("course");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
@ -80,10 +90,6 @@ namespace InternshipSystem.Repository.Migrations
.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");
@ -92,6 +98,18 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<long?>("InternshipId1")
.HasColumnName("internship_id1")
.HasColumnType("bigint");
b.Property<string>("RejectionReason")
.HasColumnName("rejection_reason")
.HasColumnType("text");
b.Property<byte[]>("Scan")
.HasColumnName("scan")
.HasColumnType("bytea");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
@ -106,37 +124,12 @@ namespace InternshipSystem.Repository.Migrations
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.HasIndex("InternshipId1")
.HasName("ix_document_internship_id1");
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")
@ -144,6 +137,10 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("id")
.HasColumnType("uuid");
b.Property<long?>("AllowedInternshipTypesId")
.HasColumnName("allowed_internship_types_id")
.HasColumnType("bigint");
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
@ -163,139 +160,15 @@ namespace InternshipSystem.Repository.Migrations
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("AllowedInternshipTypesId")
.HasName("ix_editions_allowed_internship_types_id");
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")
@ -334,25 +207,24 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
b.Property<string>("Type")
.HasColumnName("type")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.HasIndex("EditionId")
.HasName("ix_internship_types_edition_id");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
@ -360,40 +232,52 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<float?>("Grade")
.HasColumnName("grade")
.HasColumnType("real");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<long?>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_report_fields");
.HasName("pk_internship");
b.ToTable("report_fields");
b.HasIndex("EditionId")
.HasName("ix_internship_edition_id");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
b.HasIndex("InternshipProgramId")
.HasName("ix_internship_internship_program_id");
b.HasIndex("InternshipRegistrationId")
.HasName("ix_internship_internship_registration_id");
b.HasIndex("ReportId")
.HasName("ix_internship_report_id");
b.HasIndex("StudentId")
.HasName("ix_internship_student_id");
b.ToTable("internship");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
@ -405,9 +289,78 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_internship_program");
b.ToTable("internship_program");
});
modelBuilder.Entity("InternshipSystem.Core.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<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
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<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.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.Property<string>("SiteAddress")
.HasColumnName("site_address")
.HasColumnType("text");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_report");
@ -487,25 +440,6 @@ namespace InternshipSystem.Repository.Migrations
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")
@ -527,15 +461,15 @@ namespace InternshipSystem.Repository.Migrations
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.Property<long>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
b.Property<long>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
b.HasKey("InternshipProgramId", "InternshipSubjectId")
.HasName("pk_program_subject");
b.HasIndex("InternshipSubjectId")
@ -544,36 +478,6 @@ namespace InternshipSystem.Repository.Migrations
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)
@ -622,73 +526,71 @@ namespace InternshipSystem.Repository.Migrations
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Documentation")
b.HasOne("InternshipSystem.Core.Internship", null)
.WithMany("Approvals")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internships_internship_id");
});
.HasConstraintName("fk_document_internship_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();
b.HasOne("InternshipSystem.Core.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId1")
.HasConstraintName("fk_document_internship_internship_id1");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "AllowedInternshipTypes")
.WithMany()
.HasForeignKey("AllowedInternshipTypesId")
.HasConstraintName("fk_editions_internship_types_allowed_internship_types_id");
b.HasOne("InternshipSystem.Core.Course", "Course")
.WithMany()
.HasForeignKey("CourseId")
.HasConstraintName("fk_editions_courses_course_id");
.HasConstraintName("fk_editions_course_course_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.HasOne("InternshipSystem.Core.Edition", null)
.WithMany("AvailableInternshipTypes")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internship_types_editions_edition_id");
});
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("Internships")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internships_editions_edition_id");
.HasConstraintName("fk_internship_editions_edition_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
b.HasOne("InternshipSystem.Core.InternshipProgram", "InternshipProgram")
.WithMany()
.HasForeignKey("InternshipProgramId")
.HasConstraintName("fk_internship_internship_program_internship_program_id");
b.HasOne("InternshipSystem.Core.InternshipRegistration", "InternshipRegistration")
.WithMany()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_internships_internship_registration_internship_registration");
.HasConstraintName("fk_internship_internship_registration_internship_registration_");
b.HasOne("InternshipSystem.Core.Report", "Report")
.WithMany()
.HasForeignKey("ReportId")
.HasConstraintName("fk_internships_report_report_id");
.HasConstraintName("fk_internship_report_report_id");
b.HasOne("InternshipSystem.Core.Student", "Student")
.WithMany()
.HasForeignKey("StudentId")
.HasConstraintName("fk_internships_students_student_id");
.HasConstraintName("fk_internship_students_student_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", 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")
b1.Property<long>("InternshipProgramId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
@ -710,32 +612,33 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("phone_number")
.HasColumnType("text");
b1.HasKey("InternshipRegistrationId")
.HasName("pk_internship_registration");
b1.HasKey("InternshipProgramId")
.HasName("pk_internship_program");
b1.ToTable("internship_registration");
b1.ToTable("internship_program");
b1.WithOwner()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
.HasForeignKey("InternshipProgramId")
.HasConstraintName("fk_mentor_internship_program_internship_program_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", 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")
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
.WithMany()
.HasForeignKey("InternshipTypeId")
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.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");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
@ -757,10 +660,10 @@ namespace InternshipSystem.Repository.Migrations
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")
b.HasOne("InternshipSystem.Core.InternshipProgram", "Program")
.WithMany("ChosenSubjects")
.HasForeignKey("InternshipProgramId")
.HasConstraintName("fk_program_subject_internship_program_internship_program_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -771,23 +674,6 @@ namespace InternshipSystem.Repository.Migrations
.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
}
}

View File

@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
public partial class Init : Migration
public partial class init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@ -15,8 +15,7 @@ namespace InternshipSystem.Repository.Migrations
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)
name = table.Column<string>(nullable: true)
},
constraints: table =>
{
@ -24,17 +23,33 @@ namespace InternshipSystem.Repository.Migrations
});
migrationBuilder.CreateTable(
name: "courses",
name: "course",
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)
name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_courses", x => x.id);
table.PrimaryKey("pk_course", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_program",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
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),
state = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_program", x => x.id);
});
migrationBuilder.CreateTable(
@ -51,23 +66,6 @@ namespace InternshipSystem.Repository.Migrations
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
@ -75,32 +73,14 @@ namespace InternshipSystem.Repository.Migrations
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)
range = table.Column<int>(nullable: false),
site_address = table.Column<string>(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
@ -147,7 +127,6 @@ namespace InternshipSystem.Repository.Migrations
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 =>
@ -162,24 +141,27 @@ namespace InternshipSystem.Repository.Migrations
});
migrationBuilder.CreateTable(
name: "editions",
name: "program_subject",
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)
internship_program_id = table.Column<long>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_editions", x => x.id);
table.PrimaryKey("pk_program_subject", x => new { x.internship_program_id, x.internship_subject_id });
table.ForeignKey(
name: "fk_editions_courses_course_id",
column: x => x.course_id,
principalTable: "courses",
name: "fk_program_subject_internship_program_internship_program_id",
column: x => x.internship_program_id,
principalTable: "internship_program",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
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(
@ -190,17 +172,10 @@ namespace InternshipSystem.Repository.Migrations
.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)
state = table.Column<int>(nullable: false)
},
constraints: table =>
{
@ -217,36 +192,28 @@ namespace InternshipSystem.Repository.Migrations
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",
name: "editions",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
internship_type_id = table.Column<long>(nullable: false)
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),
allowed_internship_types_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_edition_internship_type", x => new { x.edition_id, x.internship_type_id });
table.PrimaryKey("pk_editions", x => x.id);
table.ForeignKey(
name: "fk_edition_internship_type_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
name: "fk_editions_course_course_id",
column: x => x.course_id,
principalTable: "course",
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);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -274,64 +241,47 @@ namespace InternshipSystem.Repository.Migrations
});
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",
name: "internship",
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),
internship_program_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.PrimaryKey("pk_internship", x => x.id);
table.ForeignKey(
name: "fk_internships_editions_edition_id",
name: "fk_internship_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internships_internship_registration_internship_registration",
name: "fk_internship_internship_program_internship_program_id",
column: x => x.internship_program_id,
principalTable: "internship_program",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_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",
name: "fk_internship_report_report_id",
column: x => x.report_id,
principalTable: "report",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internships_students_student_id",
name: "fk_internship_students_student_id",
column: x => x.student_id,
principalTable: "students",
principalColumn: "id",
@ -339,27 +289,25 @@ namespace InternshipSystem.Repository.Migrations
});
migrationBuilder.CreateTable(
name: "program_subject",
name: "internship_types",
columns: table => new
{
internship_registration_id = table.Column<long>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false)
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
type = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true),
edition_id = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_program_subject", x => new { x.internship_registration_id, x.internship_subject_id });
table.PrimaryKey("pk_internship_types", x => x.id);
table.ForeignKey(
name: "fk_program_subject_internship_registration_internship_registrat",
column: x => x.internship_registration_id,
principalTable: "internship_registration",
name: "fk_internship_types_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
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);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -369,41 +317,28 @@ namespace InternshipSystem.Repository.Migrations
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true),
scan = table.Column<byte[]>(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)
rejection_reason = table.Column<string>(nullable: true),
internship_id = table.Column<long>(nullable: true),
internship_id1 = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_document", x => x.id);
table.ForeignKey(
name: "fk_document_internships_internship_id",
name: "fk_document_internship_internship_id",
column: x => x.internship_id,
principalTable: "internships",
principalTable: "internship",
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",
name: "fk_document_internship_internship_id1",
column: x => x.internship_id1,
principalTable: "internship",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
@ -417,20 +352,50 @@ namespace InternshipSystem.Repository.Migrations
column: "internship_id");
migrationBuilder.CreateIndex(
name: "ix_edition_internship_type_internship_type_id",
table: "edition_internship_type",
column: "internship_type_id");
name: "ix_document_internship_id1",
table: "document",
column: "internship_id1");
migrationBuilder.CreateIndex(
name: "ix_edition_subject_internship_subject_id",
table: "edition_subject",
column: "internship_subject_id");
migrationBuilder.CreateIndex(
name: "ix_editions_allowed_internship_types_id",
table: "editions",
column: "allowed_internship_types_id");
migrationBuilder.CreateIndex(
name: "ix_editions_course_id",
table: "editions",
column: "course_id");
migrationBuilder.CreateIndex(
name: "ix_internship_edition_id",
table: "internship",
column: "edition_id");
migrationBuilder.CreateIndex(
name: "ix_internship_internship_program_id",
table: "internship",
column: "internship_program_id");
migrationBuilder.CreateIndex(
name: "ix_internship_internship_registration_id",
table: "internship",
column: "internship_registration_id");
migrationBuilder.CreateIndex(
name: "ix_internship_report_id",
table: "internship",
column: "report_id");
migrationBuilder.CreateIndex(
name: "ix_internship_student_id",
table: "internship",
column: "student_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_branch_address_id",
table: "internship_registration",
@ -447,43 +412,40 @@ namespace InternshipSystem.Repository.Migrations
column: "type_id");
migrationBuilder.CreateIndex(
name: "ix_internships_edition_id",
table: "internships",
name: "ix_internship_types_edition_id",
table: "internship_types",
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");
migrationBuilder.AddForeignKey(
name: "fk_internship_registration_internship_types_type_id",
table: "internship_registration",
column: "type_id",
principalTable: "internship_types",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "fk_editions_internship_types_allowed_internship_types_id",
table: "editions",
column: "allowed_internship_types_id",
principalTable: "internship_types",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "document_scan");
migrationBuilder.DropForeignKey(
name: "fk_internship_types_editions_edition_id",
table: "internship_types");
migrationBuilder.DropTable(
name: "edition_internship_type");
name: "document");
migrationBuilder.DropTable(
name: "edition_subject");
@ -491,26 +453,17 @@ namespace InternshipSystem.Repository.Migrations
migrationBuilder.DropTable(
name: "program_subject");
migrationBuilder.DropTable(
name: "report_field_edition");
migrationBuilder.DropTable(
name: "static_pages");
migrationBuilder.DropTable(
name: "document");
name: "internship");
migrationBuilder.DropTable(
name: "internship_subject");
migrationBuilder.DropTable(
name: "report_fields");
migrationBuilder.DropTable(
name: "internships");
migrationBuilder.DropTable(
name: "editions");
name: "internship_program");
migrationBuilder.DropTable(
name: "internship_registration");
@ -522,16 +475,19 @@ namespace InternshipSystem.Repository.Migrations
name: "students");
migrationBuilder.DropTable(
name: "courses");
name: "branch_office");
migrationBuilder.DropTable(
name: "branch_office");
name: "companies");
migrationBuilder.DropTable(
name: "editions");
migrationBuilder.DropTable(
name: "internship_types");
migrationBuilder.DropTable(
name: "companies");
name: "course");
}
}
}

View File

@ -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
}
}
}

View File

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

View File

@ -31,10 +31,6 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_branch_office");
@ -60,16 +56,30 @@ namespace InternshipSystem.Repository.Migrations
.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.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.HasKey("Id")
.HasName("pk_course");
b.ToTable("course");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
@ -78,10 +88,6 @@ namespace InternshipSystem.Repository.Migrations
.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");
@ -90,6 +96,18 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<long?>("InternshipId1")
.HasColumnName("internship_id1")
.HasColumnType("bigint");
b.Property<string>("RejectionReason")
.HasColumnName("rejection_reason")
.HasColumnType("text");
b.Property<byte[]>("Scan")
.HasColumnName("scan")
.HasColumnType("bytea");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
@ -104,37 +122,12 @@ namespace InternshipSystem.Repository.Migrations
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.HasIndex("InternshipId1")
.HasName("ix_document_internship_id1");
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")
@ -142,6 +135,10 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("id")
.HasColumnType("uuid");
b.Property<long?>("AllowedInternshipTypesId")
.HasColumnName("allowed_internship_types_id")
.HasColumnType("bigint");
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
@ -161,139 +158,15 @@ namespace InternshipSystem.Repository.Migrations
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("AllowedInternshipTypesId")
.HasName("ix_editions_allowed_internship_types_id");
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")
@ -332,29 +205,24 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<string>("Label")
.HasColumnName("label")
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<string>("Type")
.HasColumnName("type")
.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.HasIndex("EditionId")
.HasName("ix_internship_types_edition_id");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
@ -362,40 +230,52 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<float?>("Grade")
.HasColumnName("grade")
.HasColumnType("real");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<long?>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_report_fields");
.HasName("pk_internship");
b.ToTable("report_fields");
b.HasIndex("EditionId")
.HasName("ix_internship_edition_id");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
b.HasIndex("InternshipProgramId")
.HasName("ix_internship_internship_program_id");
b.HasIndex("InternshipRegistrationId")
.HasName("ix_internship_internship_registration_id");
b.HasIndex("ReportId")
.HasName("ix_internship_report_id");
b.HasIndex("StudentId")
.HasName("ix_internship_student_id");
b.ToTable("internship");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
@ -407,9 +287,78 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_internship_program");
b.ToTable("internship_program");
});
modelBuilder.Entity("InternshipSystem.Core.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<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
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<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.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.Property<string>("SiteAddress")
.HasColumnName("site_address")
.HasColumnType("text");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_report");
@ -489,25 +438,6 @@ namespace InternshipSystem.Repository.Migrations
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")
@ -529,15 +459,15 @@ namespace InternshipSystem.Repository.Migrations
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.Property<long>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
b.Property<long>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
b.HasKey("InternshipProgramId", "InternshipSubjectId")
.HasName("pk_program_subject");
b.HasIndex("InternshipSubjectId")
@ -546,36 +476,6 @@ namespace InternshipSystem.Repository.Migrations
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)
@ -624,73 +524,71 @@ namespace InternshipSystem.Repository.Migrations
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Documentation")
b.HasOne("InternshipSystem.Core.Internship", null)
.WithMany("Approvals")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internships_internship_id");
});
.HasConstraintName("fk_document_internship_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();
b.HasOne("InternshipSystem.Core.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId1")
.HasConstraintName("fk_document_internship_internship_id1");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "AllowedInternshipTypes")
.WithMany()
.HasForeignKey("AllowedInternshipTypesId")
.HasConstraintName("fk_editions_internship_types_allowed_internship_types_id");
b.HasOne("InternshipSystem.Core.Course", "Course")
.WithMany()
.HasForeignKey("CourseId")
.HasConstraintName("fk_editions_courses_course_id");
.HasConstraintName("fk_editions_course_course_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.HasOne("InternshipSystem.Core.Edition", null)
.WithMany("AvailableInternshipTypes")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internship_types_editions_edition_id");
});
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("Internships")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internships_editions_edition_id");
.HasConstraintName("fk_internship_editions_edition_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
b.HasOne("InternshipSystem.Core.InternshipProgram", "InternshipProgram")
.WithMany()
.HasForeignKey("InternshipProgramId")
.HasConstraintName("fk_internship_internship_program_internship_program_id");
b.HasOne("InternshipSystem.Core.InternshipRegistration", "InternshipRegistration")
.WithMany()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_internships_internship_registration_internship_registration");
.HasConstraintName("fk_internship_internship_registration_internship_registration_");
b.HasOne("InternshipSystem.Core.Report", "Report")
.WithMany()
.HasForeignKey("ReportId")
.HasConstraintName("fk_internships_report_report_id");
.HasConstraintName("fk_internship_report_report_id");
b.HasOne("InternshipSystem.Core.Student", "Student")
.WithMany()
.HasForeignKey("StudentId")
.HasConstraintName("fk_internships_students_student_id");
.HasConstraintName("fk_internship_students_student_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", 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")
b1.Property<long>("InternshipProgramId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
@ -712,32 +610,33 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("phone_number")
.HasColumnType("text");
b1.HasKey("InternshipRegistrationId")
.HasName("pk_internship_registration");
b1.HasKey("InternshipProgramId")
.HasName("pk_internship_program");
b1.ToTable("internship_registration");
b1.ToTable("internship_program");
b1.WithOwner()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
.HasForeignKey("InternshipProgramId")
.HasConstraintName("fk_mentor_internship_program_internship_program_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", 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")
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
.WithMany()
.HasForeignKey("InternshipTypeId")
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.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");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
@ -759,10 +658,10 @@ namespace InternshipSystem.Repository.Migrations
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")
b.HasOne("InternshipSystem.Core.InternshipProgram", "Program")
.WithMany("ChosenSubjects")
.HasForeignKey("InternshipProgramId")
.HasConstraintName("fk_program_subject_internship_program_internship_program_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -773,23 +672,6 @@ namespace InternshipSystem.Repository.Migrations
.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
}
}

View File

@ -1,16 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading;
using InternshipSystem.Api.Commands;
using InternshipSystem.Api.Controllers;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.UseCases;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Machine.Specifications;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace InternshipSystem.Api.Test
{
@ -64,105 +56,4 @@ namespace InternshipSystem.Api.Test
private static JsonSerializerOptions options;
private static CasUserProfile result;
}
class When_doint_whatever
{
private Establish context = () =>
{
var db = new InternshipDbContext(new DbContextOptionsBuilder<InternshipDbContext>()
.UseLoggerFactory(LoggerFactory.Create(b => b.AddConsole()))
.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu")
.Options);
var company = Company.CreateCompany("a", "b");
var internship = db.Editions.First();
var list = new List<UpdateRegistrationForm> {null}.Select(form => form.Company).ToList();
db.Companies.Add(company);
db.SaveChanges();
};
private It should_whatev = () => true.ShouldBeTrue();
}
class When_writing_tests_only_for_debug_because_i_gave_up_on_code_quality
{
private Establish context = () =>
{
var db = new InternshipDbContext(new DbContextOptionsBuilder<InternshipDbContext>()
.UseLoggerFactory(LoggerFactory.Create(b => b.AddConsole()))
.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu")
.Options);
var ed = db.Editions
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(t => t.InternshipType)
.Include(e => e.AvailableSubjects)
.ThenInclude(t => t.Subject)
.First();
var user = new User
{
PersonNumber = 1
};
var ir = db.Entry(ed)
.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)
.Where(i => i.Student.Id == user.PersonNumber)
.First();
var useCase = new UpdateInternshipRegistrationUseCase(db, ir, ed, user);
var update = new UpdateRegistrationForm
{
Subjects = new List<long>
{
1,
2,
3
},
Type = 1
};
var task = useCase.UpdateInternshipRegistration(update, CancellationToken.None);
task.Wait();
var result = task.Result;
db.SaveChanges();
ir = db.Entry(ed)
.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)
.Where(i => i.Student.Id == user.PersonNumber)
.First();
};
private It should_nop = () => true.ShouldBeTrue();
}
}

View File

@ -1,4 +1,4 @@
using InternshipSystem.Core.Entity.Internship;
using System;
using Machine.Specifications;
// ReSharper disable InconsistentNaming