Oj tak tak modeliczq +49
This commit is contained in:
		
							parent
							
								
									ba31cd89df
								
							
						
					
					
						commit
						af2f225f6c
					
				| @ -6,14 +6,13 @@ services: | |||||||
|     environment: |     environment: | ||||||
|       CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=szwoniu" |       CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=szwoniu" | ||||||
|       ASPNETCORE_ENVIRONMENT: Development |       ASPNETCORE_ENVIRONMENT: Development | ||||||
|       APIPREFIX: /api |  | ||||||
|     depends_on:  |     depends_on:  | ||||||
|       - db.postgres |       - db.postgres | ||||||
|     ports:  |     ports:  | ||||||
|       - 8080:80 |       - 8080:80 | ||||||
| 
 | 
 | ||||||
|   db.postgres: |   db.postgres: | ||||||
|     image: mborzyszkowski/internship_system_db:latest |     image: postgres:latest | ||||||
|     restart: always |     restart: always | ||||||
|     environment: |     environment: | ||||||
|       POSTGRES_PASSWORD: szwoniu |       POSTGRES_PASSWORD: szwoniu | ||||||
|  | |||||||
| @ -1,60 +1,60 @@ | |||||||
| using System.Threading.Tasks; | // using System.Threading.Tasks; | ||||||
| using InternshipSystem.Repository; | // using InternshipSystem.Repository; | ||||||
| using Microsoft.AspNetCore.Mvc; | // using Microsoft.AspNetCore.Mvc; | ||||||
| 
 | // | ||||||
| namespace Internship.Api.Controller | // namespace Internship.Api.Controller | ||||||
| { | // { | ||||||
|     [ApiController] | //     [ApiController] | ||||||
|     [Route("admin")] | //     [Route("admin")] | ||||||
|     public class AdminController : ControllerBase | //     public class AdminController : ControllerBase | ||||||
|     { | //     { | ||||||
|         public AdminController(DatabaseFiller fillerService) | //         public AdminController(DatabaseFiller fillerService) | ||||||
|         { | //         { | ||||||
|             FillerService = fillerService; | //             FillerService = fillerService; | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         public DatabaseFiller FillerService { get; } | //         public DatabaseFiller FillerService { get; } | ||||||
| 
 | // | ||||||
|          | //          | ||||||
|         [HttpPost("fill")]  | //         [HttpPost("fill")]  | ||||||
|         public async Task<IActionResult> Fill() { | //         public async Task<IActionResult> Fill() { | ||||||
|             await FillerService.FillCompany(); | //             await FillerService.FillCompany(); | ||||||
|             await FillerService.FillInterns(); | //             await FillerService.FillInterns(); | ||||||
|             await FillerService.FillInternshipTypes(); | //             await FillerService.FillInternshipTypes(); | ||||||
|             await FillerService.FillEditions(); | //             await FillerService.FillEditions(); | ||||||
|             await FillerService.FillInternShips(); | //             await FillerService.FillInternShips(); | ||||||
|             return Ok(); | //             return Ok(); | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         [HttpPost("fill/companies")] | //         [HttpPost("fill/companies")] | ||||||
|         public async Task<IActionResult> FillCompaniesAsync() | //         public async Task<IActionResult> FillCompaniesAsync() | ||||||
|         { | //         { | ||||||
|             await FillerService.FillCompany(); | //             await FillerService.FillCompany(); | ||||||
|             return Ok(); | //             return Ok(); | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         [HttpPost("fill/interns")] | //         [HttpPost("fill/interns")] | ||||||
|         public async Task<IActionResult> FillInternsAsync() { | //         public async Task<IActionResult> FillInternsAsync() { | ||||||
|             await FillerService.FillInterns(); | //             await FillerService.FillInterns(); | ||||||
|             return Ok(); | //             return Ok(); | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         [HttpPost("fill/internshiptypes")] | //         [HttpPost("fill/internshiptypes")] | ||||||
|         public async Task<IActionResult> FillInternshipTypesAsync() { | //         public async Task<IActionResult> FillInternshipTypesAsync() { | ||||||
|             await FillerService.FillInternshipTypes(); | //             await FillerService.FillInternshipTypes(); | ||||||
|             return Ok(); | //             return Ok(); | ||||||
|         }      | //         }      | ||||||
| 
 | // | ||||||
|         [HttpPost("fill/editions")] | //         [HttpPost("fill/editions")] | ||||||
|         public async Task<IActionResult> FillEditionsAsync() { | //         public async Task<IActionResult> FillEditionsAsync() { | ||||||
|             await FillerService.FillEditions(); | //             await FillerService.FillEditions(); | ||||||
|             return Ok(); | //             return Ok(); | ||||||
|         } | //         } | ||||||
|          | //          | ||||||
|         [HttpPost("fill/internships")] | //         [HttpPost("fill/internships")] | ||||||
|         public async Task<IActionResult> FillInternShipsAsync() { | //         public async Task<IActionResult> FillInternShipsAsync() { | ||||||
|             await FillerService.FillInternShips(); | //             await FillerService.FillInternShips(); | ||||||
|             return Ok(); | //             return Ok(); | ||||||
|         } | //         } | ||||||
|     } | //     } | ||||||
| } | // } | ||||||
| @ -1,40 +1,40 @@ | |||||||
| using System.Collections.Generic; | // using System.Collections.Generic; | ||||||
| using System.Linq; | // using System.Linq; | ||||||
| using System.Threading; | // using System.Threading; | ||||||
| using System.Threading.Tasks; | // using System.Threading.Tasks; | ||||||
| using InternshipSystem.Api.Queries; | // using InternshipSystem.Api.Queries; | ||||||
| using InternshipSystem.Core; | // using InternshipSystem.Core; | ||||||
| using InternshipSystem.Repository; | // using InternshipSystem.Repository; | ||||||
| using Microsoft.AspNetCore.Http; | // using Microsoft.AspNetCore.Http; | ||||||
| using Microsoft.AspNetCore.Mvc; | // using Microsoft.AspNetCore.Mvc; | ||||||
| using Microsoft.EntityFrameworkCore; | // using Microsoft.EntityFrameworkCore; | ||||||
| 
 | // | ||||||
| namespace InternshipSystem.Api.Controllers | // namespace InternshipSystem.Api.Controllers | ||||||
| { | // { | ||||||
|     [ApiController] | //     [ApiController] | ||||||
|     [Route("companies")] | //     [Route("companies")] | ||||||
|     public class CompaniesController : ControllerBase | //     public class CompaniesController : ControllerBase | ||||||
|     { | //     { | ||||||
|         public CompaniesController(InternshipDbContext context) | //         public CompaniesController(InternshipDbContext context) | ||||||
|         { | //         { | ||||||
|             Context = context; | //             Context = context; | ||||||
|         } | //         } | ||||||
|         private InternshipDbContext Context { get; } | //         private InternshipDbContext Context { get; } | ||||||
| 
 | // | ||||||
|         /// <summary> | //         /// <summary> | ||||||
|         /// Get companies matching provided paginated query | //         /// Get companies matching provided paginated query | ||||||
|         /// </summary> | //         /// </summary> | ||||||
|         /// <param name="searchQuery">Paginated query description</param> | //         /// <param name="searchQuery">Paginated query description</param> | ||||||
|         /// <returns>Part of companies collection</returns> | //         /// <returns>Part of companies collection</returns> | ||||||
|         [HttpGet] | //         [HttpGet] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | //         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
|         public async Task<IReadOnlyCollection<Company>> SearchByNameAsync([FromQuery] SearchQuery searchQuery, CancellationToken cancellationToken) => | //         public async Task<IReadOnlyCollection<Company>> SearchByNameAsync([FromQuery] SearchQuery searchQuery, CancellationToken cancellationToken) => | ||||||
|             await Context.Companies | //             await Context.Companies | ||||||
|                 .Where(c => c.Name.ToLower().Contains(searchQuery.Query.ToLower())) | //                 .Where(c => c.Name.ToLower().Contains(searchQuery.Query.ToLower())) | ||||||
|                 .OrderBy(o => o.Name) | //                 .OrderBy(o => o.Name) | ||||||
|                 .Skip(searchQuery.Page * searchQuery.PerPage) | //                 .Skip(searchQuery.Page * searchQuery.PerPage) | ||||||
|                 .Take(searchQuery.PerPage) | //                 .Take(searchQuery.PerPage) | ||||||
|                 .ToListAsync(cancellationToken); | //                 .ToListAsync(cancellationToken); | ||||||
|     } | //     } | ||||||
| 
 | // | ||||||
| } | // } | ||||||
| @ -29,7 +29,7 @@ namespace InternshipSystem.Api | |||||||
|                     var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); |                     var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); | ||||||
|                     options.IncludeXmlComments(xmlPath); |                     options.IncludeXmlComments(xmlPath); | ||||||
|                 }) |                 }) | ||||||
|                 .AddScoped<DatabaseFiller>() |                 // .AddScoped<DatabaseFiller>() | ||||||
|                 .AddControllers() |                 .AddControllers() | ||||||
|             ; |             ; | ||||||
|          |          | ||||||
|  | |||||||
							
								
								
									
										9
									
								
								src/InternshipSystem.Core/Entity/Approval.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/InternshipSystem.Core/Entity/Approval.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Approval | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public byte[] Scan { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								src/InternshipSystem.Core/Entity/BranchOffice.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/InternshipSystem.Core/Entity/BranchOffice.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class BranchOffice | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  | 
 | ||||||
|  |         public BranchAddress Address { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										28
									
								
								src/InternshipSystem.Core/Entity/Company.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/InternshipSystem.Core/Entity/Company.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Linq; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Company | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public Nip Nip { get; set; } | ||||||
|  |         public string Name { get; set; } | ||||||
|  |         public RangeOfActivity Range { get; set; } | ||||||
|  |         public List<BranchOffice> Branches { get; set; } | ||||||
|  | 
 | ||||||
|  |         public Company CreateCompany(Nip nip, RangeOfActivity range, string name) | ||||||
|  |         { | ||||||
|  |             return new Company | ||||||
|  |             { | ||||||
|  |                 Nip = nip, | ||||||
|  |                 Range = range, | ||||||
|  |                 Name = name | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void AddBranchAddress(BranchAddress branch) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								src/InternshipSystem.Core/Entity/Course.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/InternshipSystem.Core/Entity/Course.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Course | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public string Name { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								src/InternshipSystem.Core/Entity/Document.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/InternshipSystem.Core/Entity/Document.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Document | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public string Description { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										25
									
								
								src/InternshipSystem.Core/Entity/Edition.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/InternshipSystem.Core/Entity/Edition.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Edition | ||||||
|  |     { | ||||||
|  |         public long Id { get; private set; } | ||||||
|  |         public DateTime EditionStart { get; private set; } | ||||||
|  |         public DateTime EditionFinish { get; private set; } | ||||||
|  |         public DateTime ReportingStart { get; private set; } | ||||||
|  |         public Course Course { get; private set; } | ||||||
|  |         public IReadOnlyCollection<InternshipSubject> AvailableSubjects { get; private set; } | ||||||
|  | 
 | ||||||
|  |         public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart) | ||||||
|  |         { | ||||||
|  |             return new Edition | ||||||
|  |             { | ||||||
|  |                 EditionStart = start, | ||||||
|  |                 EditionFinish = end, | ||||||
|  |                 ReportingStart = reportingStart | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										16
									
								
								src/InternshipSystem.Core/Entity/Internship/Internship.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/InternshipSystem.Core/Entity/Internship/Internship.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | 
 | ||||||
|  | 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<Approval> Approvals { get; set; } | ||||||
|  |         public List<Document> Documents { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,12 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class InternshipProgram | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public Mentor Mentor { get; set; } | ||||||
|  |         public List<InternshipSubject> ChosenSubjects { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,15 @@ | |||||||
|  | using System; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class InternshipRegistration | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public Company Company { get; set; } | ||||||
|  |         public BranchOffice BranchAddress { get; set; } | ||||||
|  |         public DateTime Start { get; set; } | ||||||
|  |         public DateTime End { get; set; } | ||||||
|  |         public InternshipType Type { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								src/InternshipSystem.Core/Entity/Report.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/InternshipSystem.Core/Entity/Report.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Report | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										14
									
								
								src/InternshipSystem.Core/Entity/Student.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/InternshipSystem.Core/Entity/Student.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public class Student | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public int AlbumNumber { get; set; } | ||||||
|  |         public string FirstName { get; set; } | ||||||
|  |         public string LastName { get; set; } | ||||||
|  |         public string Email { get; set; } | ||||||
|  |         public int Semester { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,11 @@ | |||||||
|  | using System.Threading; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core.Interface.Repository | ||||||
|  | { | ||||||
|  |     public interface IInternshipRepository | ||||||
|  |     { | ||||||
|  |         Task SaveInternship(Internship internship, CancellationToken token); | ||||||
|  |         Task<Internship> GetStudentsInternship(Student student, CancellationToken token); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,11 @@ | |||||||
|  | using System.Threading; | ||||||
|  | using System.Threading.Tasks; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Core.Interface.Repository | ||||||
|  | { | ||||||
|  |     public interface IStudentRepository | ||||||
|  |     { | ||||||
|  |         Task<Student> GetAlbumNumber(int album, CancellationToken token); | ||||||
|  |         Task SaveStudent(Student student, CancellationToken token); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,6 +1,6 @@ | |||||||
| namespace InternshipSystem.Core | namespace InternshipSystem.Core | ||||||
| { | { | ||||||
|     public class Address |     public struct BranchAddress | ||||||
|     { |     { | ||||||
|         public string Street { get; set; } |         public string Street { get; set; } | ||||||
|         public string Building { get; set; } |         public string Building { get; set; } | ||||||
							
								
								
									
										10
									
								
								src/InternshipSystem.Core/ValueObject/DocumentState.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/InternshipSystem.Core/ValueObject/DocumentState.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public enum DocumentState | ||||||
|  |     { | ||||||
|  |         Draft, | ||||||
|  |         Submitted, | ||||||
|  |         Accepted, | ||||||
|  |         Rejected | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,7 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public struct InternshipSubject | ||||||
|  |     { | ||||||
|  |         public string Description { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,8 +1,7 @@ | |||||||
| namespace InternshipSystem.Core | namespace InternshipSystem.Core | ||||||
| { | { | ||||||
|     public class InternshipType |     public struct InternshipType | ||||||
|     { |     { | ||||||
|         public int Id { get; set; } |  | ||||||
|         public string Type { get; set; } |         public string Type { get; set; } | ||||||
|         public string Description { get; set; } |         public string Description { get; set; } | ||||||
|     } |     } | ||||||
							
								
								
									
										10
									
								
								src/InternshipSystem.Core/ValueObject/Mentor.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/InternshipSystem.Core/ValueObject/Mentor.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public struct Mentor | ||||||
|  |     { | ||||||
|  |         public string FirstName { get; set; } | ||||||
|  |         public string LastName { get; set; } | ||||||
|  |         public string Email { get; set; } | ||||||
|  |         public PhoneNumber PhoneNumber { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										18
									
								
								src/InternshipSystem.Core/ValueObject/Nip.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/InternshipSystem.Core/ValueObject/Nip.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public struct Nip | ||||||
|  |     { | ||||||
|  |         private readonly string nip; | ||||||
|  | 
 | ||||||
|  |         private Nip(string maybeNip) | ||||||
|  |         { | ||||||
|  |             nip = maybeNip; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public static implicit operator string(Nip nip) => | ||||||
|  |             nip.nip; | ||||||
|  | 
 | ||||||
|  |         public static implicit operator Nip(string maybeNip) => | ||||||
|  |             new Nip(maybeNip); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										6
									
								
								src/InternshipSystem.Core/ValueObject/PhoneNumber.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/InternshipSystem.Core/ValueObject/PhoneNumber.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public struct PhoneNumber | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								src/InternshipSystem.Core/ValueObject/RangeOfActivity.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/InternshipSystem.Core/ValueObject/RangeOfActivity.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | namespace InternshipSystem.Core | ||||||
|  | { | ||||||
|  |     public enum RangeOfActivity | ||||||
|  |     { | ||||||
|  |         International, | ||||||
|  |         National, | ||||||
|  |         Local | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,330 +1,330 @@ | |||||||
| using System; | // using System; | ||||||
| using System.Collections.Generic; | // using System.Collections.Generic; | ||||||
| using System.Linq; | // using System.Linq; | ||||||
| using System.Threading.Tasks; | // using System.Threading.Tasks; | ||||||
| using InternshipSystem.Core; | // using InternshipSystem.Core; | ||||||
| 
 | // | ||||||
| namespace InternshipSystem.Repository | // namespace InternshipSystem.Repository | ||||||
| { | // { | ||||||
|     public class DatabaseFiller | //     public class DatabaseFiller | ||||||
|     { | //     { | ||||||
|         public DatabaseFiller(InternshipDbContext context) | //         public DatabaseFiller(InternshipDbContext context) | ||||||
|         { | //         { | ||||||
|             Context = context; | //             Context = context; | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         public InternshipDbContext Context { get; } | //         public InternshipDbContext Context { get; } | ||||||
| 
 | // | ||||||
|         public async Task FillCompany() | //         public async Task FillCompany() | ||||||
|         { | //         { | ||||||
|             var companies = new List<Company> | //             var companies = new List<Company> | ||||||
|             { | //             { | ||||||
|                 new Company  | //                 new Company  | ||||||
|                 { | //                 { | ||||||
|                     Name = "Intel", | //                     Name = "Intel", | ||||||
|                     SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), | //                     SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), | ||||||
|                     Nip = "9570752316", | //                     Nip = "9570752316", | ||||||
|                     Range = RangeOfActivities.International, | //                     Range = RangeOfActivities.International, | ||||||
|                     Branches = new List<BranchOffice> | //                     Branches = new List<BranchOffice> | ||||||
|                     { | //                     { | ||||||
|                         new BranchOffice | //                         new BranchOffice | ||||||
|                         { | //                         { | ||||||
|                             Address = new Address | //                             Address = new Address | ||||||
|                             { | //                             { | ||||||
|                                 City = "Gdańsk", | //                                 City = "Gdańsk", | ||||||
|                                 Street = "ul. Słowackiego", | //                                 Street = "ul. Słowackiego", | ||||||
|                                 Building = "173", | //                                 Building = "173", | ||||||
|                                 PostalCode = "80-298", | //                                 PostalCode = "80-298", | ||||||
|                                 Country = "Poland" | //                                 Country = "Poland" | ||||||
|                             } | //                             } | ||||||
|                         }, | //                         }, | ||||||
|                         new BranchOffice | //                         new BranchOffice | ||||||
|                         { | //                         { | ||||||
|                             Address = new Address | //                             Address = new Address | ||||||
|                             { | //                             { | ||||||
|                                 City = "Gdańsk", | //                                 City = "Gdańsk", | ||||||
|                                 Street = "Jana z Kolna", | //                                 Street = "Jana z Kolna", | ||||||
|                                 Building = "11", | //                                 Building = "11", | ||||||
|                                 PostalCode = "80-001", | //                                 PostalCode = "80-001", | ||||||
|                                 Country = "Poland" | //                                 Country = "Poland" | ||||||
|                             } | //                             } | ||||||
|                         }, | //                         }, | ||||||
|                         new BranchOffice | //                         new BranchOffice | ||||||
|                         { | //                         { | ||||||
|                             Address = new Address | //                             Address = new Address | ||||||
|                             { | //                             { | ||||||
|                                 City = "Boston", | //                                 City = "Boston", | ||||||
|                                 Street = "State St", | //                                 Street = "State St", | ||||||
|                                 Building = "53", | //                                 Building = "53", | ||||||
|                                 PostalCode = "MA 02109", | //                                 PostalCode = "MA 02109", | ||||||
|                                 Country = "Stany Zjednoczone" | //                                 Country = "Stany Zjednoczone" | ||||||
|                             } | //                             } | ||||||
|                         } | //                         } | ||||||
|                     } | //                     } | ||||||
|                 }, | //                 }, | ||||||
|                 new Company | //                 new Company | ||||||
|                 { | //                 { | ||||||
|                     Name = "Asseco Poland", | //                     Name = "Asseco Poland", | ||||||
|                     SiteAddress = new Uri("http://pl.asseco.com"), | //                     SiteAddress = new Uri("http://pl.asseco.com"), | ||||||
|                     Nip = "5842068320", | //                     Nip = "5842068320", | ||||||
|                     Range = RangeOfActivities.National, | //                     Range = RangeOfActivities.National, | ||||||
|                     Branches = new List<BranchOffice> | //                     Branches = new List<BranchOffice> | ||||||
|                     { | //                     { | ||||||
|                         new BranchOffice | //                         new BranchOffice | ||||||
|                         { | //                         { | ||||||
|                             Address = new Address | //                             Address = new Address | ||||||
|                             { | //                             { | ||||||
|                                 City = "Gdańsk", | //                                 City = "Gdańsk", | ||||||
|                                 Street = "ul. Podolska", | //                                 Street = "ul. Podolska", | ||||||
|                                 Building = "21", | //                                 Building = "21", | ||||||
|                                 PostalCode = "81-321", | //                                 PostalCode = "81-321", | ||||||
|                                 Country = "Poland" | //                                 Country = "Poland" | ||||||
|                             } | //                             } | ||||||
|                         }, | //                         }, | ||||||
|                         new BranchOffice | //                         new BranchOffice | ||||||
|                         { | //                         { | ||||||
|                             Address = new Address | //                             Address = new Address | ||||||
|                             { | //                             { | ||||||
|                                 City = "Wrocław", | //                                 City = "Wrocław", | ||||||
|                                 Street = "Traugutta", | //                                 Street = "Traugutta", | ||||||
|                                 Building = "1/7", | //                                 Building = "1/7", | ||||||
|                                 PostalCode = "50-449", | //                                 PostalCode = "50-449", | ||||||
|                                 Country = "Poland" | //                                 Country = "Poland" | ||||||
|                             } | //                             } | ||||||
|                         } | //                         } | ||||||
|                     } | //                     } | ||||||
|                 } | //                 } | ||||||
|             }; | //             }; | ||||||
|             Context.Companies.AddRange(companies); | //             Context.Companies.AddRange(companies); | ||||||
|             await Context.SaveChangesAsync(); | //             await Context.SaveChangesAsync(); | ||||||
|         }  | //         }  | ||||||
| 
 | // | ||||||
|         public async Task FillInterns()  | //         public async Task FillInterns()  | ||||||
|         { | //         { | ||||||
|             var interns = new List<Intern> | //             var interns = new List<Intern> | ||||||
|             { | //             { | ||||||
|                 new Intern { | //                 new Intern { | ||||||
|                     Name = "Jan", | //                     Name = "Jan", | ||||||
|                     Surname = "Kowalski", | //                     Surname = "Kowalski", | ||||||
|                     AlbumNumber = "123456", | //                     AlbumNumber = "123456", | ||||||
|                     Email = "s123456@student.pg.edu.pl", | //                     Email = "s123456@student.pg.edu.pl", | ||||||
|                     Semester = 4, | //                     Semester = 4, | ||||||
|                     Course = new Course | //                     Course = new Course | ||||||
|                     { | //                     { | ||||||
|                         Name = "Informatyka", | //                         Name = "Informatyka", | ||||||
|                         DesiredSemesters = new List<int> { 4, 6 }, | //                         DesiredSemesters = new List<int> { 4, 6 }, | ||||||
|                         ProgramEntries = new List<InternshipProgramEntry> | //                         ProgramEntries = new List<InternshipProgramEntry> | ||||||
|                         { | //                         { | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych." | //                                 Description = "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych." | ||||||
|                             }, | //                             }, | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Implementacja polityki bezpieczeństwa informacji w firmie lub instytucji, instalacja ochrony antywirusowej, konfiguracja zapór ogniowych." | //                                 Description = "Implementacja polityki bezpieczeństwa informacji w firmie lub instytucji, instalacja ochrony antywirusowej, konfiguracja zapór ogniowych." | ||||||
|                             }, | //                             }, | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Instalacja, konfiguracja i administracja oprogramowania, w szczególnościsystemów operacyjnychiserwerów aplikacji." | //                                 Description = "Instalacja, konfiguracja i administracja oprogramowania, w szczególnościsystemów operacyjnychiserwerów aplikacji." | ||||||
|                             }, | //                             }, | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań." | //                                 Description = "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań." | ||||||
|                             } | //                             } | ||||||
|                         } | //                         } | ||||||
|                     } | //                     } | ||||||
|                 }, | //                 }, | ||||||
|                 new Intern { | //                 new Intern { | ||||||
|                     Name = "Adam", | //                     Name = "Adam", | ||||||
|                     Surname = "Kołek", | //                     Surname = "Kołek", | ||||||
|                     AlbumNumber = "102137", | //                     AlbumNumber = "102137", | ||||||
|                     Email = "s102137@student.pg.edu.pl", | //                     Email = "s102137@student.pg.edu.pl", | ||||||
|                     Semester = 6, | //                     Semester = 6, | ||||||
|                     Course = new Course  | //                     Course = new Course  | ||||||
|                     { | //                     { | ||||||
|                         Name = "Robotyka", | //                         Name = "Robotyka", | ||||||
|                         DesiredSemesters = new List<int> { 6 }, | //                         DesiredSemesters = new List<int> { 6 }, | ||||||
|                         ProgramEntries = new List<InternshipProgramEntry> | //                         ProgramEntries = new List<InternshipProgramEntry> | ||||||
|                         { | //                         { | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Testowanie oprogramowania, także z wykorzystaniem narzędzi do testowania automatycznego." | //                                 Description = "Testowanie oprogramowania, także z wykorzystaniem narzędzi do testowania automatycznego." | ||||||
|                             }, | //                             }, | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Wykorzystanie otwartych komponentów programowych z uwzględnieniem prawnych zależności pomiędzy nimi a produktem wynikowym." | //                                 Description = "Wykorzystanie otwartych komponentów programowych z uwzględnieniem prawnych zależności pomiędzy nimi a produktem wynikowym." | ||||||
|                             }, | //                             }, | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Projektowanie i implementacja baz danych oraz badanie ich wydajności." | //                                 Description = "Projektowanie i implementacja baz danych oraz badanie ich wydajności." | ||||||
|                             }, | //                             }, | ||||||
|                             new InternshipProgramEntry | //                             new InternshipProgramEntry | ||||||
|                             { | //                             { | ||||||
|                                 Description = "Projektowanie i prototypowaniezaawansowanychinterfejsów użytkownika." | //                                 Description = "Projektowanie i prototypowaniezaawansowanychinterfejsów użytkownika." | ||||||
|                             } | //                             } | ||||||
|                         } | //                         } | ||||||
|                     } | //                     } | ||||||
|                 } | //                 } | ||||||
|             }; | //             }; | ||||||
|             Context.Interns.AddRange(interns); | //             Context.Interns.AddRange(interns); | ||||||
|             await Context.SaveChangesAsync(); | //             await Context.SaveChangesAsync(); | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         public async Task FillInternshipTypes() { | //         public async Task FillInternshipTypes() { | ||||||
|             var internshipTypes = new List<InternshipType> | //             var internshipTypes = new List<InternshipType> | ||||||
|             { | //             { | ||||||
|                 new InternshipType  | //                 new InternshipType  | ||||||
|                 { | //                 { | ||||||
|                     Type = "FreeInternship", | //                     Type = "FreeInternship", | ||||||
|                     Description = "Praktyka bezpłatna", | //                     Description = "Praktyka bezpłatna", | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType  | //                 new InternshipType  | ||||||
|                 { | //                 { | ||||||
|                     Type = "GraduateInternship" | //                     Type = "GraduateInternship" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType  | //                 new InternshipType  | ||||||
|                 { | //                 { | ||||||
|                     Type = "FreeApprenticeship" | //                     Type = "FreeApprenticeship" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType | //                 new InternshipType | ||||||
|                 { | //                 { | ||||||
|                     Type = "PaidApprenticeship", | //                     Type = "PaidApprenticeship", | ||||||
|                     Description = "np. przemysłowy" | //                     Description = "np. przemysłowy" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType | //                 new InternshipType | ||||||
|                 { | //                 { | ||||||
|                     Type = "ForeignInternship", | //                     Type = "ForeignInternship", | ||||||
|                     Description = "np. IAESTE, ERASMUS" | //                     Description = "np. IAESTE, ERASMUS" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType | //                 new InternshipType | ||||||
|                 { | //                 { | ||||||
|                     Type = "UOP" | //                     Type = "UOP" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType | //                 new InternshipType | ||||||
|                 { | //                 { | ||||||
|                     Type = "UD" | //                     Type = "UD" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType | //                 new InternshipType | ||||||
|                 { | //                 { | ||||||
|                     Type = "UZ" | //                     Type = "UZ" | ||||||
|                 }, | //                 }, | ||||||
|                 new InternshipType | //                 new InternshipType | ||||||
|                 { | //                 { | ||||||
|                     Type = "Other", | //                     Type = "Other", | ||||||
|                     Description = "Należy wprowadzić samodzielnie" | //                     Description = "Należy wprowadzić samodzielnie" | ||||||
|                 } | //                 } | ||||||
|             }; | //             }; | ||||||
|             Context.InternshipTypes.AddRange(internshipTypes); | //             Context.InternshipTypes.AddRange(internshipTypes); | ||||||
|             await Context.SaveChangesAsync(); | //             await Context.SaveChangesAsync(); | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         public async Task FillEditions() { | //         public async Task FillEditions() { | ||||||
|             var editions = new List<Edition> | //             var editions = new List<Edition> | ||||||
|             { | //             { | ||||||
|                 new Edition  | //                 new Edition  | ||||||
|                 { | //                 { | ||||||
|                     StartDate = new DateTime(2000, 5, 10), | //                     StartDate = new DateTime(2000, 5, 10), | ||||||
|                     EndDate = new DateTime(2000, 11, 10), | //                     EndDate = new DateTime(2000, 11, 10), | ||||||
|                     IPPDeadlineDate = new DateTime(2000, 9, 30), | //                     IPPDeadlineDate = new DateTime(2000, 9, 30), | ||||||
|                     Subjects = new List<InternshipProgramEntry> | //                     Subjects = new List<InternshipProgramEntry> | ||||||
|                     { | //                     { | ||||||
|                         Context.InternshipProgramEntries | //                         Context.InternshipProgramEntries | ||||||
|                             .Where(i => i.Description == "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych.") | //                             .Where(i => i.Description == "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych.") | ||||||
|                             .First(), | //                             .First(), | ||||||
|                         Context.InternshipProgramEntries | //                         Context.InternshipProgramEntries | ||||||
|                             .Where(i => i.Description == "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań.") | //                             .Where(i => i.Description == "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań.") | ||||||
|                             .First() | //                             .First() | ||||||
|                     } | //                     } | ||||||
|                 } | //                 } | ||||||
|             }; | //             }; | ||||||
|             Context.Editions.AddRange(editions); | //             Context.Editions.AddRange(editions); | ||||||
|             await Context.SaveChangesAsync(); | //             await Context.SaveChangesAsync(); | ||||||
|         } | //         } | ||||||
| 
 | // | ||||||
|         public async Task FillInternShips() { | //         public async Task FillInternShips() { | ||||||
|             var edition = Context.Editions.First(); | //             var edition = Context.Editions.First(); | ||||||
| 
 | // | ||||||
|             var intenrships = new List<Internship> | //             var intenrships = new List<Internship> | ||||||
|             { | //             { | ||||||
|                 new Internship | //                 new Internship | ||||||
|                 { | //                 { | ||||||
|                     Intern = Context.Interns.Where(i => i.AlbumNumber == "123456").First(), | //                     Intern = Context.Interns.Where(i => i.AlbumNumber == "123456").First(), | ||||||
|                     Edition = edition, | //                     Edition = edition, | ||||||
|                     BranchOffice =  | //                     BranchOffice =  | ||||||
|                         Context.Companies | //                         Context.Companies | ||||||
|                             .Where(c => c.Nip == "9570752316")      //Intel | //                             .Where(c => c.Nip == "9570752316")      //Intel | ||||||
|                             .First() | //                             .First() | ||||||
|                             .Branches | //                             .Branches | ||||||
|                             .First(), | //                             .First(), | ||||||
|                     Type = Context.InternshipTypes.Where(t => t.Type == "UOP").First(), | //                     Type = Context.InternshipTypes.Where(t => t.Type == "UOP").First(), | ||||||
|                     StartDate = new DateTime(2000, 7, 1), | //                     StartDate = new DateTime(2000, 7, 1), | ||||||
|                     EndDate = new DateTime(2000, 8, 30), | //                     EndDate = new DateTime(2000, 8, 30), | ||||||
|                     IsAccepted = false, | //                     IsAccepted = false, | ||||||
|                     DeanAcceptance = new DeanAcceptance | //                     DeanAcceptance = new DeanAcceptance | ||||||
|                     { | //                     { | ||||||
|                         AcceptanceDate = new DateTime(2000, 6, 26), | //                         AcceptanceDate = new DateTime(2000, 6, 26), | ||||||
|                         IsDeansAcceptanceRequired = true, | //                         IsDeansAcceptanceRequired = true, | ||||||
|                         Reason = DeanAcceptanceReason.Semester | //                         Reason = DeanAcceptanceReason.Semester | ||||||
|                     }, | //                     }, | ||||||
|                     Insurance = new Insurance | //                     Insurance = new Insurance | ||||||
|                     { | //                     { | ||||||
|                         InsuranceDeliveryDate = new DateTime(2000, 6, 29), | //                         InsuranceDeliveryDate = new DateTime(2000, 6, 29), | ||||||
|                         IsInsuranceRequired = true | //                         IsInsuranceRequired = true | ||||||
|                     },  | //                     },  | ||||||
|                     LengthInWeeks = 9, | //                     LengthInWeeks = 9, | ||||||
|                     Grade = 0, | //                     Grade = 0, | ||||||
|                     Program = new List<InternshipProgramEntry> | //                     Program = new List<InternshipProgramEntry> | ||||||
|                     { | //                     { | ||||||
|                         edition.Subjects.First() | //                         edition.Subjects.First() | ||||||
|                     }, | //                     }, | ||||||
|                     Mentor = new Mentor | //                     Mentor = new Mentor | ||||||
|                     { | //                     { | ||||||
|                         Name = "Horacy", | //                         Name = "Horacy", | ||||||
|                         Surname = "Wościcki", | //                         Surname = "Wościcki", | ||||||
|                         Email = "howos@intel.com", | //                         Email = "howos@intel.com", | ||||||
|                         Phone = "605-555-555" | //                         Phone = "605-555-555" | ||||||
|                     } | //                     } | ||||||
|                 }, | //                 }, | ||||||
|                 new Internship | //                 new Internship | ||||||
|                 { | //                 { | ||||||
|                     Intern = Context.Interns.Where(i => i.AlbumNumber == "102137").First(), | //                     Intern = Context.Interns.Where(i => i.AlbumNumber == "102137").First(), | ||||||
|                     Edition = edition, | //                     Edition = edition, | ||||||
|                     BranchOffice =  | //                     BranchOffice =  | ||||||
|                         Context.Companies | //                         Context.Companies | ||||||
|                             .Where(c => c.Nip == "5842068320")      //Asseco | //                             .Where(c => c.Nip == "5842068320")      //Asseco | ||||||
|                             .First() | //                             .First() | ||||||
|                             .Branches | //                             .Branches | ||||||
|                             .First(), | //                             .First(), | ||||||
|                     Type = Context.InternshipTypes.Where(t => t.Type == "UZ").First(), | //                     Type = Context.InternshipTypes.Where(t => t.Type == "UZ").First(), | ||||||
|                     StartDate = new DateTime(2000, 7, 1), | //                     StartDate = new DateTime(2000, 7, 1), | ||||||
|                     EndDate = new DateTime(2000, 8, 30), | //                     EndDate = new DateTime(2000, 8, 30), | ||||||
|                     IsAccepted = false, | //                     IsAccepted = false, | ||||||
|                     DeanAcceptance = new DeanAcceptance | //                     DeanAcceptance = new DeanAcceptance | ||||||
|                     { | //                     { | ||||||
|                         IsDeansAcceptanceRequired = false | //                         IsDeansAcceptanceRequired = false | ||||||
|                     }, | //                     }, | ||||||
|                     Insurance = new Insurance | //                     Insurance = new Insurance | ||||||
|                     { | //                     { | ||||||
|                         InsuranceDeliveryDate = new DateTime(2000, 6, 29), | //                         InsuranceDeliveryDate = new DateTime(2000, 6, 29), | ||||||
|                         IsInsuranceRequired = true | //                         IsInsuranceRequired = true | ||||||
|                     },  | //                     },  | ||||||
|                     LengthInWeeks = 9, | //                     LengthInWeeks = 9, | ||||||
|                     Grade = 0, | //                     Grade = 0, | ||||||
|                     Program = new List<InternshipProgramEntry> | //                     Program = new List<InternshipProgramEntry> | ||||||
|                     { | //                     { | ||||||
|                         edition.Subjects.First() | //                         edition.Subjects.First() | ||||||
|                     }, | //                     }, | ||||||
|                     Mentor = new Mentor | //                     Mentor = new Mentor | ||||||
|                     { | //                     { | ||||||
|                         Name = "Horacy", | //                         Name = "Horacy", | ||||||
|                         Surname = "Wościcki", | //                         Surname = "Wościcki", | ||||||
|                         Email = "howos@intel.com", | //                         Email = "howos@intel.com", | ||||||
|                         Phone = "605-555-555" | //                         Phone = "605-555-555" | ||||||
|                     } | //                     } | ||||||
|                 } | //                 } | ||||||
|             }; | //             }; | ||||||
|             Context.Internships.AddRange(intenrships); | //             Context.Internships.AddRange(intenrships); | ||||||
|             await Context.SaveChangesAsync(); | //             await Context.SaveChangesAsync(); | ||||||
|         } | //         } | ||||||
|     }  | //     }  | ||||||
| } | // } | ||||||
| @ -1,18 +1,25 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
| using Microsoft.EntityFrameworkCore; | using Microsoft.EntityFrameworkCore; | ||||||
| using InternshipSystem.Core; | using InternshipSystem.Core; | ||||||
|  | using InternshipSystem.Repository.Model; | ||||||
| 
 | 
 | ||||||
| namespace InternshipSystem.Repository | namespace InternshipSystem.Repository | ||||||
| { | { | ||||||
|     public class InternshipDbContext : DbContext |     public class InternshipDbContext : DbContext | ||||||
|     { |     { | ||||||
|         public DbSet<Internship> Internships { get; set; } |         public DbSet<Document> Documents { get; set; } | ||||||
|         public DbSet<Company> Companies { get; set; } |         public DbSet<Course> Courses { get; set; } | ||||||
|         public DbSet<Edition> Editions { get; set; } |         public DbSet<CompanyReadModel> Companies { get; set; } | ||||||
|         public DbSet<Report> Reports { get; set; } |         public DbSet<InternshipSubjectReadModel> Subjects { get; set; } | ||||||
|         public DbSet<Intern> Interns { get; set; } |         public DbSet<EditionReadModel> Editions { get; set; } | ||||||
|         public DbSet<InternshipType> InternshipTypes { get; set; } |         public DbSet<Student> Students { get; set; } | ||||||
|         public DbSet<Mentor> Mentors { get; set; } |         public DbSet<Approval> Approvals { get; set; } | ||||||
|         public DbSet<InternshipProgramEntry> InternshipProgramEntries { get; set; } |         public DbSet<BranchOfficeReadModel> BranchOffices { get; set; } | ||||||
|  |         public DbSet<InternshipRegistrationReadModel> Registrations { get; set; } | ||||||
|  |         public DbSet<InternshipProgramReadModel> Programs { get; set; } | ||||||
|  |         public DbSet<InternshipReadModel> Internships { get; set; } | ||||||
|  |         public DbSet<InternshipTypeReadModel> InternshipTypes { get; set; } | ||||||
|  | 
 | ||||||
|         public InternshipDbContext(DbContextOptions<InternshipDbContext> options) |         public InternshipDbContext(DbContextOptions<InternshipDbContext> options) | ||||||
|             : base(options) |             : base(options) | ||||||
|         {           |         {           | ||||||
| @ -22,24 +29,39 @@ namespace InternshipSystem.Repository | |||||||
|             optionsBuilder |             optionsBuilder | ||||||
|                 .UseSnakeCaseNamingConvention(); |                 .UseSnakeCaseNamingConvention(); | ||||||
| 
 | 
 | ||||||
|         protected override void OnModelCreating(ModelBuilder modelBuilder) { |         protected override void OnModelCreating(ModelBuilder modelBuilder) | ||||||
|             modelBuilder |         { | ||||||
|                 .Entity<Internship>(ie => { |             modelBuilder.Entity<ProgramSubject>(builder => | ||||||
|                     ie.OwnsOne(i => i.DeanAcceptance); |             { | ||||||
|                     ie.OwnsOne(i => i.Insurance); |                 builder | ||||||
|                 }); |                     .HasKey(subject => new { subject.InternshipProgramId, subject.InternshipSubjectId }); | ||||||
|                  |                  | ||||||
|             modelBuilder |                 builder | ||||||
|                 .Entity<Company>() |                     .HasOne<InternshipProgramReadModel>() | ||||||
|                 .HasKey(c => c.Nip); |                     .WithMany(model => model.ChosenSubjects) | ||||||
|  |                     .HasForeignKey(subject => subject.InternshipProgramId); | ||||||
|                  |                  | ||||||
|             modelBuilder |                 builder | ||||||
|                 .Entity<BranchOffice>() |                     .HasOne<InternshipSubjectReadModel>() | ||||||
|                 .OwnsOne(b => b.Address); |                     .WithMany() | ||||||
|  |                     .HasForeignKey(subject => subject.InternshipSubjectId); | ||||||
|  |             }); | ||||||
|              |              | ||||||
|             modelBuilder |             modelBuilder.Entity<EditionSubject>(builder => | ||||||
|                 .Entity<Intern>() |             { | ||||||
|                 .HasKey(i => i.AlbumNumber); |                 builder | ||||||
|  |                     .HasKey(subject => new { subject.EditionId, subject.InternshipId}); | ||||||
|  |                  | ||||||
|  |                 builder | ||||||
|  |                     .HasOne<EditionReadModel>() | ||||||
|  |                     .WithMany(model => model.AvailableSubjects) | ||||||
|  |                     .HasForeignKey(p => p.EditionId); | ||||||
|  | 
 | ||||||
|  |                 builder | ||||||
|  |                     .HasOne<InternshipSubjectReadModel>() | ||||||
|  |                     .WithMany() | ||||||
|  |                     .HasForeignKey(subject => subject.InternshipId); | ||||||
|  |             }); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -1,10 +0,0 @@ | |||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class BranchOffice |  | ||||||
|     { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|         public Address Address { get; set; } |  | ||||||
|         public Company Company { get; set; } |  | ||||||
|         public int Provider { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -0,0 +1,14 @@ | |||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class BranchOfficeReadModel | ||||||
|  |     { | ||||||
|  |         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; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,15 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Company |  | ||||||
|     { |  | ||||||
|         public string Nip { get; set; } |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public RangeOfActivities Range { get; set; } |  | ||||||
|         public Uri SiteAddress { get; set; } |  | ||||||
|         public int Provider { get; set; } |  | ||||||
|         public List<BranchOffice> Branches { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										14
									
								
								src/InternshipSystem.Repository/Model/CompanyReadModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/InternshipSystem.Repository/Model/CompanyReadModel.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class CompanyReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public string Nip { get; set; } | ||||||
|  |         public string Name { get; set; } | ||||||
|  |         public RangeOfActivity Range { get; set; } | ||||||
|  |         public List<BranchOfficeReadModel> Branches { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,12 +0,0 @@ | |||||||
| using System.Collections.Generic; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Course |  | ||||||
|     { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public List<int> DesiredSemesters { get; set; } |  | ||||||
|         public List<InternshipProgramEntry> ProgramEntries { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,18 +0,0 @@ | |||||||
| using System; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class DeanAcceptance |  | ||||||
|     { |  | ||||||
|         public DateTime? AcceptanceDate { get; set; } |  | ||||||
|         public bool IsDeansAcceptanceRequired { get; set; } |  | ||||||
|         public DeanAcceptanceReason? Reason { get; set; } |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|     public enum DeanAcceptanceReason |  | ||||||
|     { |  | ||||||
|         Semester, |  | ||||||
|         Delay, |  | ||||||
|         Whatever |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,14 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Edition |  | ||||||
|     { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|         public DateTime StartDate { get; set; } |  | ||||||
|         public DateTime EndDate { get; set; } |  | ||||||
|         public DateTime IPPDeadlineDate { get; set; } |  | ||||||
|         public List<InternshipProgramEntry> Subjects { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										17
									
								
								src/InternshipSystem.Repository/Model/EditionReadModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/InternshipSystem.Repository/Model/EditionReadModel.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Collections.Immutable; | ||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class EditionReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public DateTime EditionStart { get; set; } | ||||||
|  |         public DateTime EditionFinish { get; set; } | ||||||
|  |         public DateTime ReportingStart { get; set; } | ||||||
|  |         public Course Course { get; set; } | ||||||
|  |         public ImmutableList<EditionSubject> AvailableSubjects { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								src/InternshipSystem.Repository/Model/EditionSubject.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/InternshipSystem.Repository/Model/EditionSubject.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | namespace InternshipSystem.Repository | ||||||
|  | { | ||||||
|  |     public class EditionSubject | ||||||
|  |     { | ||||||
|  |         public long EditionId { get; set; } | ||||||
|  |         public long InternshipId { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,10 +0,0 @@ | |||||||
| using System; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Insurance |  | ||||||
|     { |  | ||||||
|         public DateTime InsuranceDeliveryDate { get; set; } |  | ||||||
|         public bool IsInsuranceRequired { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,14 +0,0 @@ | |||||||
| using System; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Intern |  | ||||||
|     { |  | ||||||
|         public string AlbumNumber { get; set; } |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public string Surname { get; set; } |  | ||||||
|         public string Email { get; set; } |  | ||||||
|         public int Semester { get; set; } |  | ||||||
|         public Course Course { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,24 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| 
 |  | ||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Internship |  | ||||||
|     { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|         public Intern Intern { get; set; } |  | ||||||
|         public Edition Edition { get; set; } |  | ||||||
|         public Report Report { get; set; } |  | ||||||
|         public BranchOffice BranchOffice { get; set; } |  | ||||||
|         public InternshipType Type { get; set; } |  | ||||||
|         public DateTime StartDate { get; set; } |  | ||||||
|         public DateTime EndDate { get; set; } |  | ||||||
|         public bool IsAccepted { get; set; } |  | ||||||
|         public DeanAcceptance DeanAcceptance { get; set; } |  | ||||||
|         public Insurance Insurance { get; set; } |  | ||||||
|         public int LengthInWeeks { get; set; } |  | ||||||
|         public float Grade { get; set; } |  | ||||||
|         public List<InternshipProgramEntry> Program { get; set; } |  | ||||||
|         public Mentor Mentor { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,9 +0,0 @@ | |||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class InternshipProgramEntry |  | ||||||
|     { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|         public Course Course { get; set; } |  | ||||||
|         public string Description { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -0,0 +1,16 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class InternshipProgramReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public string FirstName { get; set; } | ||||||
|  |         public string LastName { get; set; } | ||||||
|  |         public string Email { get; set; } | ||||||
|  |         public string PhoneNumber { get; set; } | ||||||
|  |         public List<ProgramSubject> ChosenSubjects { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										16
									
								
								src/InternshipSystem.Repository/Model/InternshipReadModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/InternshipSystem.Repository/Model/InternshipReadModel.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | using System.Collections.Generic; | ||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class InternshipReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public Student Student { get; set; } | ||||||
|  |         public InternshipRegistrationReadModel InternshipRegistration { get; set; } | ||||||
|  |         public InternshipProgramReadModel InternshipProgram { get; set; } | ||||||
|  |         public Report Report { get; set; } | ||||||
|  |         public List<Approval> Approvals { get; set; } | ||||||
|  |         public List<Document> Documents { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,16 @@ | |||||||
|  | using System; | ||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class InternshipRegistrationReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public CompanyReadModel Company { get; set; } | ||||||
|  |         public BranchOfficeReadModel BranchAddress { get; set; } | ||||||
|  |         public DateTime Start { get; set; } | ||||||
|  |         public DateTime End { get; set; } | ||||||
|  |         public InternshipTypeReadModel Type { get; set; } | ||||||
|  |         public DocumentState State { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,12 @@ | |||||||
|  | using System; | ||||||
|  | using InternshipSystem.Core; | ||||||
|  | 
 | ||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class InternshipSubjectReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  | 
 | ||||||
|  |         public string Description { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,9 @@ | |||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class InternshipTypeReadModel | ||||||
|  |     { | ||||||
|  |         public long Id { get; set; } | ||||||
|  |         public string Type { get; set; } | ||||||
|  |         public string Description { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,11 +0,0 @@ | |||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Mentor { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public string Surname { get; set; } |  | ||||||
|         public string Email { get; set; } |  | ||||||
|         public string Phone { get; set; } |  | ||||||
|         public Company Company { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										8
									
								
								src/InternshipSystem.Repository/Model/ProgramSubject.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/InternshipSystem.Repository/Model/ProgramSubject.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | namespace InternshipSystem.Repository.Model | ||||||
|  | { | ||||||
|  |     public class ProgramSubject | ||||||
|  |     { | ||||||
|  |         public long InternshipProgramId { get; set; } | ||||||
|  |         public long InternshipSubjectId { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,9 +0,0 @@ | |||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public enum RangeOfActivities |  | ||||||
|     { |  | ||||||
|         Other, |  | ||||||
|         National, |  | ||||||
|         International |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,7 +0,0 @@ | |||||||
| namespace InternshipSystem.Core |  | ||||||
| { |  | ||||||
|     public class Report |  | ||||||
|     { |  | ||||||
|         public int Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user