diff --git a/src/InternshipSystem.Api/Controllers/AdminController.cs b/src/InternshipSystem.Api/Controllers/AdminController.cs index 84db31e..5c7c6b3 100644 --- a/src/InternshipSystem.Api/Controllers/AdminController.cs +++ b/src/InternshipSystem.Api/Controllers/AdminController.cs @@ -1,68 +1,68 @@ -using System.Threading.Tasks; -using InternshipSystem.Repository; -using Microsoft.AspNetCore.Mvc; - -namespace InternshipSystem.Api.Controllers -{ - [ApiController] - [Route("admin")] - public class AdminController : ControllerBase - { - public AdminController(DatabaseFiller fillerService) - { - FillerService = fillerService; - } - - public DatabaseFiller FillerService { get; } - - - [HttpPost("fill")] - public async Task Fill() { - await FillerService.FillCompany(); - await FillerService.FillStudents(); - await FillerService.FillSubjects(); - await FillerService.FillInternshipTypes(); - await FillerService.FillEditions(); - await FillerService.FillInternShips(); - return Ok(); - } - - // [HttpPost("fill/companies")] - // public async Task FillCompaniesAsync() - // { - // await FillerService.FillCompany(); - // return Ok(); - // } - // - // [HttpPost("fill/students")] - // public async Task FillStudentsAsync() { - // await FillerService.FillStudents(); - // return Ok(); - // } - // - // [HttpPost("fill/subjects")] - // public async Task FillSubjectsAsync() - // { - // await FillerService.FillSubjects(); - // return Ok(); - // } - // - // [HttpPost("fill/internshiptypes")] - // public async Task FillInternshipTypesAsync() { - // await FillerService.FillInternshipTypes(); - // return Ok(); - // } - // - // [HttpPost("fill/editions")] - // public async Task FillEditionsAsync() { - // await FillerService.FillEditions(); - // return Ok(); - // } - // - // [HttpPost("fill/internships")] - // public async Task FillInternShipsAsync() { - // await FillerService.FillInternShips(); - // return Ok(); - // } - } -} \ No newline at end of file +// using System.Threading.Tasks; +// using InternshipSystem.Repository; +// using Microsoft.AspNetCore.Mvc; +// +// namespace InternshipSystem.Api.Controllers +// { +// [ApiController] +// [Route("admin")] +// public class AdminController : ControllerBase +// { +// public AdminController(DatabaseFiller fillerService) +// { +// FillerService = fillerService; +// } +// +// public DatabaseFiller FillerService { get; } +// +// +// [HttpPost("fill")] +// public async Task Fill() { +// await FillerService.FillCompany(); +// await FillerService.FillStudents(); +// await FillerService.FillSubjects(); +// await FillerService.FillInternshipTypes(); +// await FillerService.FillEditions(); +// await FillerService.FillInternShips(); +// return Ok(); +// } +// +// // [HttpPost("fill/companies")] +// // public async Task FillCompaniesAsync() +// // { +// // await FillerService.FillCompany(); +// // return Ok(); +// // } +// // +// // [HttpPost("fill/students")] +// // public async Task FillStudentsAsync() { +// // await FillerService.FillStudents(); +// // return Ok(); +// // } +// // +// // [HttpPost("fill/subjects")] +// // public async Task FillSubjectsAsync() +// // { +// // await FillerService.FillSubjects(); +// // return Ok(); +// // } +// // +// // [HttpPost("fill/internshiptypes")] +// // public async Task FillInternshipTypesAsync() { +// // await FillerService.FillInternshipTypes(); +// // return Ok(); +// // } +// // +// // [HttpPost("fill/editions")] +// // public async Task FillEditionsAsync() { +// // await FillerService.FillEditions(); +// // return Ok(); +// // } +// // +// // [HttpPost("fill/internships")] +// // public async Task FillInternShipsAsync() { +// // await FillerService.FillInternShips(); +// // return Ok(); +// // } +// } +// } \ No newline at end of file diff --git a/src/InternshipSystem.Api/Startup.cs b/src/InternshipSystem.Api/Startup.cs index aa5f0c8..71e2992 100644 --- a/src/InternshipSystem.Api/Startup.cs +++ b/src/InternshipSystem.Api/Startup.cs @@ -29,7 +29,7 @@ namespace InternshipSystem.Api var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); options.IncludeXmlComments(xmlPath); }) - .AddScoped() + // .AddScoped() .AddControllers() ; diff --git a/src/InternshipSystem.Core/Entity/Edition.cs b/src/InternshipSystem.Core/Entity/Edition.cs index 70fd418..47c9242 100644 --- a/src/InternshipSystem.Core/Entity/Edition.cs +++ b/src/InternshipSystem.Core/Entity/Edition.cs @@ -1,16 +1,19 @@ using System; using System.Collections.Generic; +using InternshipSystem.Core.Entity.Internship; +using InternshipSystem.Core.UglyOrmArtifacts; 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 AvailableSubjects { get; private set; } + 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 List Internships { get; set; } + public List AvailableSubjects { get; set; } public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart) { diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipProgram.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipProgram.cs index 89b2eb3..71dc540 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipProgram.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipProgram.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using InternshipSystem.Core.Entity.Internship; +using InternshipSystem.Core.UglyOrmArtifacts; namespace InternshipSystem.Core { @@ -6,7 +8,7 @@ namespace InternshipSystem.Core { public long Id { get; set; } public Mentor Mentor { get; set; } - public List ChosenSubjects { get; set; } public DocumentState State { get; set; } + public List ChosenSubjects { get; set; } } } \ No newline at end of file diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs index 7861b8a..449230e 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs @@ -1,4 +1,5 @@ using System; +using InternshipSystem.Core.Entity.Internship; namespace InternshipSystem.Core { diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs new file mode 100644 index 0000000..f94b0c9 --- /dev/null +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs @@ -0,0 +1,9 @@ +namespace InternshipSystem.Core.Entity.Internship +{ + public class InternshipSubject + { + public long Id { get; set; } + + public string Description { get; set; } + } +} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/InternshipTypeReadModel.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs similarity index 61% rename from src/InternshipSystem.Repository/Model/InternshipTypeReadModel.cs rename to src/InternshipSystem.Core/Entity/Internship/InternshipType.cs index 849fe1d..d9fb97f 100644 --- a/src/InternshipSystem.Repository/Model/InternshipTypeReadModel.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs @@ -1,6 +1,6 @@ -namespace InternshipSystem.Repository.Model +namespace InternshipSystem.Core.Entity.Internship { - public class InternshipTypeReadModel + public class InternshipType { public long Id { get; set; } public string Type { get; set; } diff --git a/src/InternshipSystem.Core/UglyOrmArtifacts/EditionSubject.cs b/src/InternshipSystem.Core/UglyOrmArtifacts/EditionSubject.cs new file mode 100644 index 0000000..3514514 --- /dev/null +++ b/src/InternshipSystem.Core/UglyOrmArtifacts/EditionSubject.cs @@ -0,0 +1,12 @@ +using InternshipSystem.Core.Entity.Internship; + +namespace InternshipSystem.Core.UglyOrmArtifacts +{ + public class EditionSubject + { + public long EditionId { get; set; } + public Edition Edition { get; set; } + public long InternshipSubjectId { get; set; } + public InternshipSubject Subject { get; set; } + } +} \ No newline at end of file diff --git a/src/InternshipSystem.Core/UglyOrmArtifacts/ProgramSubject.cs b/src/InternshipSystem.Core/UglyOrmArtifacts/ProgramSubject.cs new file mode 100644 index 0000000..a3db121 --- /dev/null +++ b/src/InternshipSystem.Core/UglyOrmArtifacts/ProgramSubject.cs @@ -0,0 +1,12 @@ +using InternshipSystem.Core.Entity.Internship; + +namespace InternshipSystem.Core.UglyOrmArtifacts +{ + public class ProgramSubject + { + public long InternshipProgramId { get; set; } + public InternshipProgram Program { get; set; } + public long InternshipSubjectId { get; set; } + public InternshipSubject Subject { get; set; } + } +} \ No newline at end of file diff --git a/src/InternshipSystem.Core/ValueObject/BranchAddress.cs b/src/InternshipSystem.Core/ValueObject/BranchAddress.cs index 3538ec6..5e80133 100644 --- a/src/InternshipSystem.Core/ValueObject/BranchAddress.cs +++ b/src/InternshipSystem.Core/ValueObject/BranchAddress.cs @@ -1,6 +1,6 @@ namespace InternshipSystem.Core { - public struct BranchAddress + public class BranchAddress { public string Street { get; set; } public string Building { get; set; } diff --git a/src/InternshipSystem.Core/ValueObject/InternshipSubject.cs b/src/InternshipSystem.Core/ValueObject/InternshipSubject.cs deleted file mode 100644 index 7e4d091..0000000 --- a/src/InternshipSystem.Core/ValueObject/InternshipSubject.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace InternshipSystem.Core -{ - public struct InternshipSubject - { - public string Description { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Core/ValueObject/InternshipType.cs b/src/InternshipSystem.Core/ValueObject/InternshipType.cs deleted file mode 100644 index 5b0ca30..0000000 --- a/src/InternshipSystem.Core/ValueObject/InternshipType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace InternshipSystem.Core -{ - public struct InternshipType - { - public string Type { get; set; } - public string Description { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Core/ValueObject/Mentor.cs b/src/InternshipSystem.Core/ValueObject/Mentor.cs index 27d982d..4af5c24 100644 --- a/src/InternshipSystem.Core/ValueObject/Mentor.cs +++ b/src/InternshipSystem.Core/ValueObject/Mentor.cs @@ -1,6 +1,6 @@ namespace InternshipSystem.Core { - public struct Mentor + public class Mentor { public string FirstName { get; set; } public string LastName { get; set; } diff --git a/src/InternshipSystem.Core/ValueObject/Nip.cs b/src/InternshipSystem.Core/ValueObject/Nip.cs index 06053d7..8d853a1 100644 --- a/src/InternshipSystem.Core/ValueObject/Nip.cs +++ b/src/InternshipSystem.Core/ValueObject/Nip.cs @@ -1,8 +1,12 @@ namespace InternshipSystem.Core { - public struct Nip + public class Nip { private readonly string nip; + + public Nip() + { + } private Nip(string maybeNip) { diff --git a/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs b/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs index 29011cd..4385cbf 100644 --- a/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs +++ b/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs @@ -1,6 +1,22 @@ namespace InternshipSystem.Core { - public struct PhoneNumber + public class PhoneNumber { + private readonly string phoneNumber; + + public PhoneNumber() + { + } + + private PhoneNumber(string maybePhoneNumber) + { + phoneNumber = maybePhoneNumber; + } + + public static implicit operator string(PhoneNumber phoneNumber) => + phoneNumber.phoneNumber; + + public static implicit operator PhoneNumber(string maybephoneNumber) => + new PhoneNumber(maybephoneNumber); } } \ No newline at end of file diff --git a/src/InternshipSystem.Repository/DatabaseFiller.cs b/src/InternshipSystem.Repository/DatabaseFiller.cs index fc813a5..5ba2337 100644 --- a/src/InternshipSystem.Repository/DatabaseFiller.cs +++ b/src/InternshipSystem.Repository/DatabaseFiller.cs @@ -1,311 +1,313 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Threading.Tasks; -using InternshipSystem.Core; -using InternshipSystem.Repository.Model; -using Microsoft.EntityFrameworkCore; - -namespace InternshipSystem.Repository -{ - public class DatabaseFiller - { - public DatabaseFiller(InternshipDbContext context) - { - Context = context; - } - - public InternshipDbContext Context { get; } - - public async Task FillCompany() - { - var companies = new List - { - new CompanyReadModel - { - Name = "Intel", - SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), - Nip = "9570752316", - Range = RangeOfActivity.International, - Branches = new List - { - new BranchOfficeReadModel - { - City = "Gdańsk", - Street = "ul. Słowackiego", - Building = "173", - PostalCode = "80-298", - Country = "Poland", - }, - new BranchOfficeReadModel - { - City = "Gdańsk", - Street = "Jana z Kolna", - Building = "11", - PostalCode = "80-001", - Country = "Poland", - }, - new BranchOfficeReadModel - { - City = "Boston", - Street = "State St", - Building = "53", - PostalCode = "MA 02109", - Country = "Stany Zjednoczone", - } - } - }, - new CompanyReadModel - { - Name = "Asseco Poland", - SiteAddress = new Uri("http://pl.asseco.com"), - Nip = "5842068320", - Range = RangeOfActivity.National, - Branches = new List - { - new BranchOfficeReadModel - { - City = "Gdańsk", - Street = "ul. Podolska", - Building = "21", - PostalCode = "81-321", - Country = "Poland" - }, - new BranchOfficeReadModel - { - City = "Wrocław", - Street = "Traugutta", - Building = "1/7", - PostalCode = "50-449", - Country = "Poland" - } - } - } - }; - await Context.Companies.AddRangeAsync(companies); - await Context.SaveChangesAsync(); - } - - public async Task FillStudents() - { - var interns = new List - { - new Student - { - FirstName = "Jan", - LastName = "Kowalski", - AlbumNumber = 123456, - Email = "s123456@student.pg.edu.pl", - Semester = 4, - }, - new Student - { - FirstName = "Adam", - LastName = "Kołek", - AlbumNumber = 102137, - Email = "s102137@student.pg.edu.pl", - Semester = 6, - } - }; - await Context.Students.AddRangeAsync(interns); - await Context.SaveChangesAsync(); - } - - public async Task FillInternshipTypes() - { - var internshipTypes = new List - { - new InternshipTypeReadModel - { - Type = "FreeInternship", - Description = "Praktyka bezpłatna", - }, - new InternshipTypeReadModel - { - Type = "GraduateInternship" - }, - new InternshipTypeReadModel - { - Type = "FreeApprenticeship" - }, - new InternshipTypeReadModel - { - Type = "PaidApprenticeship", - Description = "np. przemysłowy" - }, - new InternshipTypeReadModel - { - Type = "ForeignInternship", - Description = "np. IAESTE, ERASMUS" - }, - new InternshipTypeReadModel - { - Type = "UOP" - }, - new InternshipTypeReadModel - { - Type = "UD" - }, - new InternshipTypeReadModel - { - Type = "UZ" - }, - new InternshipTypeReadModel - { - Type = "Other", - Description = "Należy wprowadzić samodzielnie" - } - }; - await Context.InternshipTypes.AddRangeAsync(internshipTypes); - await Context.SaveChangesAsync(); - } - - public async Task FillSubjects() - { - var subjects = new List - { - new InternshipSubjectReadModel - { - Description = "Modelowanie baz danych" - }, - new InternshipSubjectReadModel - { - Description = "Oprogramowywanie kart graficznych" - }, - new InternshipSubjectReadModel - { - Description = "Projektowanie UI" - } - }; - await Context.Subjects.AddRangeAsync(subjects); - await Context.SaveChangesAsync(); - } - - public async Task FillEditions() - { - var editions = new List - { - new EditionReadModel - { - EditionStart = new DateTime(2000, 5, 10), - EditionFinish = new DateTime(2000, 11, 10), - ReportingStart = new DateTime(2000, 9, 30), - AvailableSubjects = new List - { - new EditionSubject - { - InternshipId = Context.Subjects - .First(i => i.Description.Equals("Modelowanie baz danych")) - .Id, - }, - new EditionSubject - { - InternshipId = Context.Subjects - .First(i => i.Description.Equals("Oprogramowywanie kart graficznych")) - .Id - }, - new EditionSubject - { - InternshipId = Context.Subjects - .First(i => i.Description.Equals("Projektowanie UI")) - .Id - } - }.ToImmutableList(), - Course = new Course - { - Name = "Informatyka", - } - } - }; - await Context.Editions.AddRangeAsync(editions); - await Context.SaveChangesAsync(); - } - - public async Task FillInternShips() - { - var intenrships = new List - { - new InternshipReadModel - { - Student = Context.Students.First(i => i.AlbumNumber.Equals(123456)), - InternshipRegistration = new InternshipRegistrationReadModel() - { - Company = Context.Companies.First(c => c.Nip.Equals("9570752316")), //Intel - Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")), - Start = new DateTime(2000, 7, 1), - End = new DateTime(2000, 8, 30), - State = DocumentState.Submitted, - BranchAddress = - Context.Companies - .Include(c => c.Branches) - .First(c => c.Nip.Equals("9570752316")) - .Branches - .First(), - }, - InternshipProgram = new InternshipProgramReadModel() - { - FirstName = "Horacy", - LastName = "Wościcki", - Email = "howos@intel.com", - PhoneNumber = "605-555-555", - ChosenSubjects = new List - { - new ProgramSubject - { - InternshipSubjectId = - Context.Subjects - .First(s => s.Description.Equals("Projektowanie UI")) - .Id - }, - new ProgramSubject - { - InternshipSubjectId = - Context.Subjects - .First(s => s.Description.Equals("Oprogramowywanie kart graficznych")) - .Id - } - } - }, - }, - new InternshipReadModel - { - Student = Context.Students.First(i => i.AlbumNumber == 102137), - InternshipRegistration = new InternshipRegistrationReadModel() - { - Company = Context.Companies.First(c => c.Nip.Equals("5842068320")), //Asseco - Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")), - Start = new DateTime(2000, 7, 1), - End = new DateTime(2000, 8, 30), - State = DocumentState.Submitted, - BranchAddress = - Context.Companies - .Include(c => c.Branches) - .First(c => c.Nip.Equals("5842068320")) - .Branches - .First(), - }, - InternshipProgram = new InternshipProgramReadModel() - { - FirstName = "Henryk", - LastName = "Polaciński", - Email = "hepol@asseco.pl", - PhoneNumber = "555-525-545", - ChosenSubjects = new List - { - new ProgramSubject - { - InternshipSubjectId = - Context.Subjects - .First(s => s.Description.Equals("Modelowanie baz danych")) - .Id - } - }, - }, - }, - }; - await Context.Internships.AddRangeAsync(intenrships); - await Context.SaveChangesAsync(); - } - } -} \ No newline at end of file +// using System; +// using System.Collections.Generic; +// using System.Collections.Immutable; +// using System.Linq; +// using System.Threading.Tasks; +// using InternshipSystem.Core; +// using InternshipSystem.Core.Entity.Internship; +// using InternshipSystem.Core.UglyOrmArtifacts; +// using InternshipSystem.Repository.Model; +// using Microsoft.EntityFrameworkCore; +// +// namespace InternshipSystem.Repository +// { +// public class DatabaseFiller +// { +// public DatabaseFiller(InternshipDbContext context) +// { +// Context = context; +// } +// +// public InternshipDbContext Context { get; } +// +// public async Task FillCompany() +// { +// var companies = new List +// { +// new CompanyReadModel +// { +// Name = "Intel", +// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), +// Nip = "9570752316", +// Range = RangeOfActivity.International, +// Branches = new List +// { +// new BranchOfficeReadModel +// { +// City = "Gdańsk", +// Street = "ul. Słowackiego", +// Building = "173", +// PostalCode = "80-298", +// Country = "Poland", +// }, +// new BranchOfficeReadModel +// { +// City = "Gdańsk", +// Street = "Jana z Kolna", +// Building = "11", +// PostalCode = "80-001", +// Country = "Poland", +// }, +// new BranchOfficeReadModel +// { +// City = "Boston", +// Street = "State St", +// Building = "53", +// PostalCode = "MA 02109", +// Country = "Stany Zjednoczone", +// } +// } +// }, +// new CompanyReadModel +// { +// Name = "Asseco Poland", +// SiteAddress = new Uri("http://pl.asseco.com"), +// Nip = "5842068320", +// Range = RangeOfActivity.National, +// Branches = new List +// { +// new BranchOfficeReadModel +// { +// City = "Gdańsk", +// Street = "ul. Podolska", +// Building = "21", +// PostalCode = "81-321", +// Country = "Poland" +// }, +// new BranchOfficeReadModel +// { +// City = "Wrocław", +// Street = "Traugutta", +// Building = "1/7", +// PostalCode = "50-449", +// Country = "Poland" +// } +// } +// } +// }; +// await Context.Companies.AddRangeAsync(companies); +// await Context.SaveChangesAsync(); +// } +// +// public async Task FillStudents() +// { +// var interns = new List +// { +// new Student +// { +// FirstName = "Jan", +// LastName = "Kowalski", +// AlbumNumber = 123456, +// Email = "s123456@student.pg.edu.pl", +// Semester = 4, +// }, +// new Student +// { +// FirstName = "Adam", +// LastName = "Kołek", +// AlbumNumber = 102137, +// Email = "s102137@student.pg.edu.pl", +// Semester = 6, +// } +// }; +// await Context.Students.AddRangeAsync(interns); +// await Context.SaveChangesAsync(); +// } +// +// public async Task FillInternshipTypes() +// { +// var internshipTypes = new List +// { +// new InternshipType +// { +// Type = "FreeInternship", +// Description = "Praktyka bezpłatna", +// }, +// new InternshipType +// { +// Type = "GraduateInternship" +// }, +// new InternshipType +// { +// Type = "FreeApprenticeship" +// }, +// new InternshipType +// { +// Type = "PaidApprenticeship", +// Description = "np. przemysłowy" +// }, +// new InternshipType +// { +// Type = "ForeignInternship", +// Description = "np. IAESTE, ERASMUS" +// }, +// new InternshipType +// { +// Type = "UOP" +// }, +// new InternshipType +// { +// Type = "UD" +// }, +// new InternshipType +// { +// Type = "UZ" +// }, +// new InternshipType +// { +// Type = "Other", +// Description = "Należy wprowadzić samodzielnie" +// } +// }; +// await Context.InternshipTypes.AddRangeAsync(internshipTypes); +// await Context.SaveChangesAsync(); +// } +// +// public async Task FillSubjects() +// { +// var subjects = new List +// { +// new InternshipSubject +// { +// Description = "Modelowanie baz danych" +// }, +// new InternshipSubject +// { +// Description = "Oprogramowywanie kart graficznych" +// }, +// new InternshipSubject +// { +// Description = "Projektowanie UI" +// } +// }; +// await Context.Subjects.AddRangeAsync(subjects); +// await Context.SaveChangesAsync(); +// } +// +// public async Task FillEditions() +// { +// var editions = new List +// { +// new EditionReadModel +// { +// EditionStart = new DateTime(2000, 5, 10), +// EditionFinish = new DateTime(2000, 11, 10), +// ReportingStart = new DateTime(2000, 9, 30), +// AvailableSubjects = new List +// { +// new EditionSubject +// { +// InternshipId = Context.Subjects +// .First(i => i.Description.Equals("Modelowanie baz danych")) +// .Id, +// }, +// new EditionSubject +// { +// InternshipId = Context.Subjects +// .First(i => i.Description.Equals("Oprogramowywanie kart graficznych")) +// .Id +// }, +// new EditionSubject +// { +// InternshipId = Context.Subjects +// .First(i => i.Description.Equals("Projektowanie UI")) +// .Id +// } +// }.ToImmutableList(), +// Course = new Course +// { +// Name = "Informatyka", +// } +// } +// }; +// await Context.Editions.AddRangeAsync(editions); +// await Context.SaveChangesAsync(); +// } +// +// public async Task FillInternShips() +// { +// var intenrships = new List +// { +// new InternshipReadModel +// { +// Student = Context.Students.First(i => i.AlbumNumber.Equals(123456)), +// InternshipRegistration = new InternshipRegistrationReadModel() +// { +// Company = Context.Companies.First(c => c.Nip.Equals("9570752316")), //Intel +// Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")), +// Start = new DateTime(2000, 7, 1), +// End = new DateTime(2000, 8, 30), +// State = DocumentState.Submitted, +// BranchAddress = +// Context.Companies +// .Include(c => c.Branches) +// .First(c => c.Nip.Equals("9570752316")) +// .Branches +// .First(), +// }, +// InternshipProgram = new InternshipProgramReadModel() +// { +// FirstName = "Horacy", +// LastName = "Wościcki", +// Email = "howos@intel.com", +// PhoneNumber = "605-555-555", +// ChosenSubjects = new List +// { +// new ProgramSubject +// { +// InternshipSubjectId = +// Context.Subjects +// .First(s => s.Description.Equals("Projektowanie UI")) +// .Id +// }, +// new ProgramSubject +// { +// InternshipSubjectId = +// Context.Subjects +// .First(s => s.Description.Equals("Oprogramowywanie kart graficznych")) +// .Id +// } +// } +// }, +// }, +// new InternshipReadModel +// { +// Student = Context.Students.First(i => i.AlbumNumber == 102137), +// InternshipRegistration = new InternshipRegistrationReadModel() +// { +// Company = Context.Companies.First(c => c.Nip.Equals("5842068320")), //Asseco +// Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")), +// Start = new DateTime(2000, 7, 1), +// End = new DateTime(2000, 8, 30), +// State = DocumentState.Submitted, +// BranchAddress = +// Context.Companies +// .Include(c => c.Branches) +// .First(c => c.Nip.Equals("5842068320")) +// .Branches +// .First(), +// }, +// InternshipProgram = new InternshipProgramReadModel() +// { +// FirstName = "Henryk", +// LastName = "Polaciński", +// Email = "hepol@asseco.pl", +// PhoneNumber = "555-525-545", +// ChosenSubjects = new List +// { +// new ProgramSubject +// { +// InternshipSubjectId = +// Context.Subjects +// .First(s => s.Description.Equals("Modelowanie baz danych")) +// .Id +// } +// }, +// }, +// }, +// }; +// await Context.Internships.AddRangeAsync(intenrships); +// await Context.SaveChangesAsync(); +// } +// } +// } \ No newline at end of file diff --git a/src/InternshipSystem.Repository/InternshipDbContext.cs b/src/InternshipSystem.Repository/InternshipDbContext.cs index 69bac5d..de1dff3 100644 --- a/src/InternshipSystem.Repository/InternshipDbContext.cs +++ b/src/InternshipSystem.Repository/InternshipDbContext.cs @@ -1,24 +1,14 @@ -using System.Collections.Generic; using Microsoft.EntityFrameworkCore; using InternshipSystem.Core; -using InternshipSystem.Repository.Model; +using InternshipSystem.Core.Entity.Internship; +using InternshipSystem.Core.UglyOrmArtifacts; namespace InternshipSystem.Repository { public class InternshipDbContext : DbContext { - public DbSet Documents { get; set; } - public DbSet Courses { get; set; } - public DbSet Companies { get; set; } - public DbSet Subjects { get; set; } - public DbSet Editions { get; set; } - public DbSet Students { get; set; } - public DbSet Approvals { get; set; } - public DbSet BranchOffices { get; set; } - public DbSet Registrations { get; set; } - public DbSet Programs { get; set; } - public DbSet Internships { get; set; } - public DbSet InternshipTypes { get; set; } + public DbSet Companies { get; set; } + public DbSet Editions { get; set; } public InternshipDbContext(DbContextOptions options) : base(options) @@ -31,18 +21,28 @@ namespace InternshipSystem.Repository protected override void OnModelCreating(ModelBuilder modelBuilder) { + modelBuilder.Entity() + .OwnsOne(bo => bo.Address); + + modelBuilder.Entity() + .OwnsOne(ip => ip.Mentor) + .OwnsOne(m => m.PhoneNumber); + + modelBuilder.Entity() + .OwnsOne(c => c.Nip); + modelBuilder.Entity(builder => { builder .HasKey(subject => new { subject.InternshipProgramId, subject.InternshipSubjectId }); builder - .HasOne() + .HasOne() .WithMany(model => model.ChosenSubjects) .HasForeignKey(subject => subject.InternshipProgramId); builder - .HasOne() + .HasOne() .WithMany() .HasForeignKey(subject => subject.InternshipSubjectId); }); @@ -50,17 +50,17 @@ namespace InternshipSystem.Repository modelBuilder.Entity(builder => { builder - .HasKey(subject => new { subject.EditionId, subject.InternshipId}); + .HasKey(subject => new { subject.EditionId, subject.InternshipSubjectId}); builder - .HasOne() + .HasOne() .WithMany(model => model.AvailableSubjects) .HasForeignKey(p => p.EditionId); builder - .HasOne() + .HasOne() .WithMany() - .HasForeignKey(subject => subject.InternshipId); + .HasForeignKey(subject => subject.InternshipSubjectId); }); } } diff --git a/src/InternshipSystem.Repository/Migrations/20200804152816_Init.Designer.cs b/src/InternshipSystem.Repository/Migrations/20200804152816_Init.Designer.cs new file mode 100644 index 0000000..465e76f --- /dev/null +++ b/src/InternshipSystem.Repository/Migrations/20200804152816_Init.Designer.cs @@ -0,0 +1,692 @@ +// +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("20200804152816_Init")] + partial class Init + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .HasAnnotation("ProductVersion", "3.1.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("InternshipSystem.Core.Approval", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("InternshipId") + .HasColumnName("internship_id") + .HasColumnType("bigint"); + + b.Property("Scan") + .HasColumnName("scan") + .HasColumnType("bytea"); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_approval"); + + b.HasIndex("InternshipId") + .HasName("ix_approval_internship_id"); + + b.ToTable("approval"); + }); + + modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("CompanyId") + .HasColumnName("company_id") + .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("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Name") + .HasColumnName("name") + .HasColumnType("text"); + + b.Property("Range") + .HasColumnName("range") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_companies"); + + b.ToTable("companies"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Name") + .HasColumnName("name") + .HasColumnType("text"); + + b.HasKey("Id") + .HasName("pk_course"); + + b.ToTable("course"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("InternshipId") + .HasColumnName("internship_id") + .HasColumnType("bigint"); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_document"); + + b.HasIndex("InternshipId") + .HasName("ix_document_internship_id"); + + b.ToTable("document"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("CourseId") + .HasColumnName("course_id") + .HasColumnType("bigint"); + + b.Property("EditionFinish") + .HasColumnName("edition_finish") + .HasColumnType("timestamp without time zone"); + + b.Property("EditionStart") + .HasColumnName("edition_start") + .HasColumnType("timestamp without time zone"); + + b.Property("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.Internship.InternshipSubject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.HasKey("Id") + .HasName("pk_internship_subject"); + + b.ToTable("internship_subject"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnName("type") + .HasColumnType("text"); + + b.HasKey("Id") + .HasName("pk_internship_type"); + + b.ToTable("internship_type"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Internship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("EditionId") + .HasColumnName("edition_id") + .HasColumnType("bigint"); + + b.Property("InternshipProgramId") + .HasColumnName("internship_program_id") + .HasColumnType("bigint"); + + b.Property("InternshipRegistrationId") + .HasColumnName("internship_registration_id") + .HasColumnType("bigint"); + + b.Property("ReportId") + .HasColumnName("report_id") + .HasColumnType("bigint"); + + b.Property("StudentId") + .HasColumnName("student_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_internship"); + + b.HasIndex("EditionId") + .HasName("ix_internship_edition_id"); + + 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.InternshipProgram", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_internship_program"); + + b.ToTable("internship_program"); + }); + + modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("BranchAddressId") + .HasColumnName("branch_address_id") + .HasColumnType("bigint"); + + b.Property("CompanyId") + .HasColumnName("company_id") + .HasColumnType("bigint"); + + b.Property("End") + .HasColumnName("end") + .HasColumnType("timestamp without time zone"); + + b.Property("Start") + .HasColumnName("start") + .HasColumnType("timestamp without time zone"); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_report"); + + b.ToTable("report"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("AlbumNumber") + .HasColumnName("album_number") + .HasColumnType("integer"); + + b.Property("Email") + .HasColumnName("email") + .HasColumnType("text"); + + b.Property("FirstName") + .HasColumnName("first_name") + .HasColumnType("text"); + + b.Property("LastName") + .HasColumnName("last_name") + .HasColumnType("text"); + + b.Property("Semester") + .HasColumnName("semester") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_student"); + + b.ToTable("student"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b => + { + b.Property("EditionId") + .HasColumnName("edition_id") + .HasColumnType("bigint"); + + b.Property("InternshipSubjectId") + .HasColumnName("internship_subject_id") + .HasColumnType("bigint"); + + b.Property("EditionId1") + .HasColumnName("edition_id1") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnName("subject_id") + .HasColumnType("bigint"); + + b.HasKey("EditionId", "InternshipSubjectId") + .HasName("pk_edition_subject"); + + b.HasIndex("EditionId1") + .HasName("ix_edition_subject_edition_id1"); + + b.HasIndex("InternshipSubjectId") + .HasName("ix_edition_subject_internship_subject_id"); + + b.HasIndex("SubjectId") + .HasName("ix_edition_subject_subject_id"); + + b.ToTable("edition_subject"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b => + { + b.Property("InternshipProgramId") + .HasColumnName("internship_program_id") + .HasColumnType("bigint"); + + b.Property("InternshipSubjectId") + .HasColumnName("internship_subject_id") + .HasColumnType("bigint"); + + b.Property("ProgramId") + .HasColumnName("program_id") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnName("subject_id") + .HasColumnType("bigint"); + + b.HasKey("InternshipProgramId", "InternshipSubjectId") + .HasName("pk_program_subject"); + + b.HasIndex("InternshipSubjectId") + .HasName("ix_program_subject_internship_subject_id"); + + b.HasIndex("ProgramId") + .HasName("ix_program_subject_program_id"); + + b.HasIndex("SubjectId") + .HasName("ix_program_subject_subject_id"); + + b.ToTable("program_subject"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Approval", b => + { + b.HasOne("InternshipSystem.Core.Internship", null) + .WithMany("Approvals") + .HasForeignKey("InternshipId") + .HasConstraintName("fk_approval_internship_internship_id"); + }); + + 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("BranchOfficeId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b1.Property("Building") + .HasColumnName("building") + .HasColumnType("text"); + + b1.Property("City") + .HasColumnName("city") + .HasColumnType("text"); + + b1.Property("Country") + .HasColumnName("country") + .HasColumnType("text"); + + b1.Property("PostalCode") + .HasColumnName("postal_code") + .HasColumnType("text"); + + b1.Property("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.Company", b => + { + b.OwnsOne("InternshipSystem.Core.Nip", "Nip", b1 => + { + b1.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b1.HasKey("CompanyId") + .HasName("pk_companies"); + + b1.ToTable("companies"); + + b1.WithOwner() + .HasForeignKey("CompanyId") + .HasConstraintName("fk_nip_companies_company_id"); + }); + }); + + modelBuilder.Entity("InternshipSystem.Core.Document", b => + { + b.HasOne("InternshipSystem.Core.Internship", null) + .WithMany("Documents") + .HasForeignKey("InternshipId") + .HasConstraintName("fk_document_internship_internship_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Edition", b => + { + b.HasOne("InternshipSystem.Core.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .HasConstraintName("fk_editions_course_course_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Internship", b => + { + b.HasOne("InternshipSystem.Core.Edition", null) + .WithMany("Internships") + .HasForeignKey("EditionId") + .HasConstraintName("fk_internship_editions_edition_id"); + + 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_internship_internship_registration_internship_registration_"); + + b.HasOne("InternshipSystem.Core.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .HasConstraintName("fk_internship_report_report_id"); + + b.HasOne("InternshipSystem.Core.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .HasConstraintName("fk_internship_student_student_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b => + { + b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 => + { + b1.Property("InternshipProgramId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b1.Property("Email") + .HasColumnName("email") + .HasColumnType("text"); + + b1.Property("FirstName") + .HasColumnName("first_name") + .HasColumnType("text"); + + b1.Property("LastName") + .HasColumnName("last_name") + .HasColumnType("text"); + + b1.HasKey("InternshipProgramId") + .HasName("pk_internship_program"); + + b1.ToTable("internship_program"); + + b1.WithOwner() + .HasForeignKey("InternshipProgramId") + .HasConstraintName("fk_mentor_internship_program_internship_program_id"); + + b1.OwnsOne("InternshipSystem.Core.PhoneNumber", "PhoneNumber", b2 => + { + b2.Property("MentorInternshipProgramId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b2.HasKey("MentorInternshipProgramId") + .HasName("pk_internship_program"); + + b2.ToTable("internship_program"); + + b2.WithOwner() + .HasForeignKey("MentorInternshipProgramId") + .HasConstraintName("fk_phone_number_internship_program_mentor_internship_program_id"); + }); + }); + }); + + modelBuilder.Entity("InternshipSystem.Core.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_type_type_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b => + { + b.HasOne("InternshipSystem.Core.Edition", null) + .WithMany("AvailableSubjects") + .HasForeignKey("EditionId") + .HasConstraintName("fk_edition_subject_editions_edition_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId1") + .HasConstraintName("fk_edition_subject_editions_edition_id1"); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", null) + .WithMany() + .HasForeignKey("InternshipSubjectId") + .HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .HasConstraintName("fk_edition_subject_internship_subject_subject_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b => + { + b.HasOne("InternshipSystem.Core.InternshipProgram", null) + .WithMany("ChosenSubjects") + .HasForeignKey("InternshipProgramId") + .HasConstraintName("fk_program_subject_internship_program_internship_program_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", null) + .WithMany() + .HasForeignKey("InternshipSubjectId") + .HasConstraintName("fk_program_subject_internship_subject_internship_subject_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.InternshipProgram", "Program") + .WithMany() + .HasForeignKey("ProgramId") + .HasConstraintName("fk_program_subject_internship_program_program_id"); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .HasConstraintName("fk_program_subject_internship_subject_subject_id"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/InternshipSystem.Repository/Migrations/20200804152816_Init.cs b/src/InternshipSystem.Repository/Migrations/20200804152816_Init.cs new file mode 100644 index 0000000..58a4573 --- /dev/null +++ b/src/InternshipSystem.Repository/Migrations/20200804152816_Init.cs @@ -0,0 +1,497 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace InternshipSystem.Repository.Migrations +{ + public partial class Init : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "companies", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(nullable: true), + range = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_companies", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "course", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + name = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_course", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "internship_program", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + first_name = table.Column(nullable: true), + last_name = table.Column(nullable: true), + email = table.Column(nullable: true), + state = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_internship_program", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "internship_subject", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_internship_subject", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "internship_type", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + type = table.Column(nullable: true), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_internship_type", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "report", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + state = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_report", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "student", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + album_number = table.Column(nullable: false), + first_name = table.Column(nullable: true), + last_name = table.Column(nullable: true), + email = table.Column(nullable: true), + semester = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_student", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "branch_office", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + street = table.Column(nullable: true), + building = table.Column(nullable: true), + city = table.Column(nullable: true), + postal_code = table.Column(nullable: true), + country = table.Column(nullable: true), + company_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_branch_office", x => x.id); + table.ForeignKey( + name: "fk_branch_office_companies_company_id", + column: x => x.company_id, + principalTable: "companies", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "editions", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + edition_start = table.Column(nullable: false), + edition_finish = table.Column(nullable: false), + reporting_start = table.Column(nullable: false), + course_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_editions", x => x.id); + table.ForeignKey( + name: "fk_editions_course_course_id", + column: x => x.course_id, + principalTable: "course", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "program_subject", + columns: table => new + { + internship_program_id = table.Column(nullable: false), + internship_subject_id = table.Column(nullable: false), + program_id = table.Column(nullable: true), + subject_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_program_subject", x => new { x.internship_program_id, x.internship_subject_id }); + table.ForeignKey( + name: "fk_program_subject_internship_program_internship_program_id", + column: x => x.internship_program_id, + principalTable: "internship_program", + 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); + table.ForeignKey( + name: "fk_program_subject_internship_program_program_id", + column: x => x.program_id, + principalTable: "internship_program", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "fk_program_subject_internship_subject_subject_id", + column: x => x.subject_id, + principalTable: "internship_subject", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "internship_registration", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + company_id = table.Column(nullable: true), + branch_address_id = table.Column(nullable: true), + start = table.Column(nullable: false), + end = table.Column(nullable: false), + type_id = table.Column(nullable: true), + state = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_internship_registration", x => x.id); + table.ForeignKey( + name: "fk_internship_registration_branch_office_branch_address_id", + column: x => x.branch_address_id, + principalTable: "branch_office", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "fk_internship_registration_companies_company_id", + column: x => x.company_id, + principalTable: "companies", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "fk_internship_registration_internship_type_type_id", + column: x => x.type_id, + principalTable: "internship_type", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "edition_subject", + columns: table => new + { + edition_id = table.Column(nullable: false), + internship_subject_id = table.Column(nullable: false), + edition_id1 = table.Column(nullable: true), + subject_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_edition_subject", x => new { x.edition_id, x.internship_subject_id }); + table.ForeignKey( + name: "fk_edition_subject_editions_edition_id", + column: x => x.edition_id, + principalTable: "editions", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_edition_subject_editions_edition_id1", + column: x => x.edition_id1, + principalTable: "editions", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "fk_edition_subject_internship_subject_internship_subject_id", + column: x => x.internship_subject_id, + principalTable: "internship_subject", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_edition_subject_internship_subject_subject_id", + column: x => x.subject_id, + principalTable: "internship_subject", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "internship", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + student_id = table.Column(nullable: true), + internship_registration_id = table.Column(nullable: true), + internship_program_id = table.Column(nullable: true), + report_id = table.Column(nullable: true), + edition_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_internship", x => x.id); + table.ForeignKey( + name: "fk_internship_editions_edition_id", + column: x => x.edition_id, + principalTable: "editions", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + 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_internship_report_report_id", + column: x => x.report_id, + principalTable: "report", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "fk_internship_student_student_id", + column: x => x.student_id, + principalTable: "student", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "approval", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + scan = table.Column(nullable: true), + state = table.Column(nullable: false), + internship_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_approval", x => x.id); + table.ForeignKey( + name: "fk_approval_internship_internship_id", + column: x => x.internship_id, + principalTable: "internship", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "document", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + description = table.Column(nullable: true), + state = table.Column(nullable: false), + internship_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_document", x => x.id); + table.ForeignKey( + name: "fk_document_internship_internship_id", + column: x => x.internship_id, + principalTable: "internship", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "ix_approval_internship_id", + table: "approval", + column: "internship_id"); + + migrationBuilder.CreateIndex( + name: "ix_branch_office_company_id", + table: "branch_office", + column: "company_id"); + + migrationBuilder.CreateIndex( + name: "ix_document_internship_id", + table: "document", + column: "internship_id"); + + migrationBuilder.CreateIndex( + name: "ix_edition_subject_edition_id1", + table: "edition_subject", + column: "edition_id1"); + + migrationBuilder.CreateIndex( + name: "ix_edition_subject_internship_subject_id", + table: "edition_subject", + column: "internship_subject_id"); + + migrationBuilder.CreateIndex( + name: "ix_edition_subject_subject_id", + table: "edition_subject", + column: "subject_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", + column: "branch_address_id"); + + migrationBuilder.CreateIndex( + name: "ix_internship_registration_company_id", + table: "internship_registration", + column: "company_id"); + + migrationBuilder.CreateIndex( + name: "ix_internship_registration_type_id", + table: "internship_registration", + column: "type_id"); + + migrationBuilder.CreateIndex( + name: "ix_program_subject_internship_subject_id", + table: "program_subject", + column: "internship_subject_id"); + + migrationBuilder.CreateIndex( + name: "ix_program_subject_program_id", + table: "program_subject", + column: "program_id"); + + migrationBuilder.CreateIndex( + name: "ix_program_subject_subject_id", + table: "program_subject", + column: "subject_id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "approval"); + + migrationBuilder.DropTable( + name: "document"); + + migrationBuilder.DropTable( + name: "edition_subject"); + + migrationBuilder.DropTable( + name: "program_subject"); + + migrationBuilder.DropTable( + name: "internship"); + + migrationBuilder.DropTable( + name: "internship_subject"); + + migrationBuilder.DropTable( + name: "editions"); + + migrationBuilder.DropTable( + name: "internship_program"); + + migrationBuilder.DropTable( + name: "internship_registration"); + + migrationBuilder.DropTable( + name: "report"); + + migrationBuilder.DropTable( + name: "student"); + + migrationBuilder.DropTable( + name: "course"); + + migrationBuilder.DropTable( + name: "branch_office"); + + migrationBuilder.DropTable( + name: "internship_type"); + + migrationBuilder.DropTable( + name: "companies"); + } + } +} diff --git a/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs b/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs new file mode 100644 index 0000000..3bb0c9c --- /dev/null +++ b/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs @@ -0,0 +1,690 @@ +// +using System; +using InternshipSystem.Repository; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace InternshipSystem.Repository.Migrations +{ + [DbContext(typeof(InternshipDbContext))] + partial class InternshipDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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.Approval", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("InternshipId") + .HasColumnName("internship_id") + .HasColumnType("bigint"); + + b.Property("Scan") + .HasColumnName("scan") + .HasColumnType("bytea"); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_approval"); + + b.HasIndex("InternshipId") + .HasName("ix_approval_internship_id"); + + b.ToTable("approval"); + }); + + modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("CompanyId") + .HasColumnName("company_id") + .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("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Name") + .HasColumnName("name") + .HasColumnType("text"); + + b.Property("Range") + .HasColumnName("range") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_companies"); + + b.ToTable("companies"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Name") + .HasColumnName("name") + .HasColumnType("text"); + + b.HasKey("Id") + .HasName("pk_course"); + + b.ToTable("course"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("InternshipId") + .HasColumnName("internship_id") + .HasColumnType("bigint"); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_document"); + + b.HasIndex("InternshipId") + .HasName("ix_document_internship_id"); + + b.ToTable("document"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("CourseId") + .HasColumnName("course_id") + .HasColumnType("bigint"); + + b.Property("EditionFinish") + .HasColumnName("edition_finish") + .HasColumnType("timestamp without time zone"); + + b.Property("EditionStart") + .HasColumnName("edition_start") + .HasColumnType("timestamp without time zone"); + + b.Property("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.Internship.InternshipSubject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.HasKey("Id") + .HasName("pk_internship_subject"); + + b.ToTable("internship_subject"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnName("type") + .HasColumnType("text"); + + b.HasKey("Id") + .HasName("pk_internship_type"); + + b.ToTable("internship_type"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Internship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("EditionId") + .HasColumnName("edition_id") + .HasColumnType("bigint"); + + b.Property("InternshipProgramId") + .HasColumnName("internship_program_id") + .HasColumnType("bigint"); + + b.Property("InternshipRegistrationId") + .HasColumnName("internship_registration_id") + .HasColumnType("bigint"); + + b.Property("ReportId") + .HasColumnName("report_id") + .HasColumnType("bigint"); + + b.Property("StudentId") + .HasColumnName("student_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_internship"); + + b.HasIndex("EditionId") + .HasName("ix_internship_edition_id"); + + 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.InternshipProgram", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_internship_program"); + + b.ToTable("internship_program"); + }); + + modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("BranchAddressId") + .HasColumnName("branch_address_id") + .HasColumnType("bigint"); + + b.Property("CompanyId") + .HasColumnName("company_id") + .HasColumnType("bigint"); + + b.Property("End") + .HasColumnName("end") + .HasColumnType("timestamp without time zone"); + + b.Property("Start") + .HasColumnName("start") + .HasColumnType("timestamp without time zone"); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("State") + .HasColumnName("state") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_report"); + + b.ToTable("report"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b.Property("AlbumNumber") + .HasColumnName("album_number") + .HasColumnType("integer"); + + b.Property("Email") + .HasColumnName("email") + .HasColumnType("text"); + + b.Property("FirstName") + .HasColumnName("first_name") + .HasColumnType("text"); + + b.Property("LastName") + .HasColumnName("last_name") + .HasColumnType("text"); + + b.Property("Semester") + .HasColumnName("semester") + .HasColumnType("integer"); + + b.HasKey("Id") + .HasName("pk_student"); + + b.ToTable("student"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b => + { + b.Property("EditionId") + .HasColumnName("edition_id") + .HasColumnType("bigint"); + + b.Property("InternshipSubjectId") + .HasColumnName("internship_subject_id") + .HasColumnType("bigint"); + + b.Property("EditionId1") + .HasColumnName("edition_id1") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnName("subject_id") + .HasColumnType("bigint"); + + b.HasKey("EditionId", "InternshipSubjectId") + .HasName("pk_edition_subject"); + + b.HasIndex("EditionId1") + .HasName("ix_edition_subject_edition_id1"); + + b.HasIndex("InternshipSubjectId") + .HasName("ix_edition_subject_internship_subject_id"); + + b.HasIndex("SubjectId") + .HasName("ix_edition_subject_subject_id"); + + b.ToTable("edition_subject"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b => + { + b.Property("InternshipProgramId") + .HasColumnName("internship_program_id") + .HasColumnType("bigint"); + + b.Property("InternshipSubjectId") + .HasColumnName("internship_subject_id") + .HasColumnType("bigint"); + + b.Property("ProgramId") + .HasColumnName("program_id") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnName("subject_id") + .HasColumnType("bigint"); + + b.HasKey("InternshipProgramId", "InternshipSubjectId") + .HasName("pk_program_subject"); + + b.HasIndex("InternshipSubjectId") + .HasName("ix_program_subject_internship_subject_id"); + + b.HasIndex("ProgramId") + .HasName("ix_program_subject_program_id"); + + b.HasIndex("SubjectId") + .HasName("ix_program_subject_subject_id"); + + b.ToTable("program_subject"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Approval", b => + { + b.HasOne("InternshipSystem.Core.Internship", null) + .WithMany("Approvals") + .HasForeignKey("InternshipId") + .HasConstraintName("fk_approval_internship_internship_id"); + }); + + 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("BranchOfficeId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b1.Property("Building") + .HasColumnName("building") + .HasColumnType("text"); + + b1.Property("City") + .HasColumnName("city") + .HasColumnType("text"); + + b1.Property("Country") + .HasColumnName("country") + .HasColumnType("text"); + + b1.Property("PostalCode") + .HasColumnName("postal_code") + .HasColumnType("text"); + + b1.Property("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.Company", b => + { + b.OwnsOne("InternshipSystem.Core.Nip", "Nip", b1 => + { + b1.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b1.HasKey("CompanyId") + .HasName("pk_companies"); + + b1.ToTable("companies"); + + b1.WithOwner() + .HasForeignKey("CompanyId") + .HasConstraintName("fk_nip_companies_company_id"); + }); + }); + + modelBuilder.Entity("InternshipSystem.Core.Document", b => + { + b.HasOne("InternshipSystem.Core.Internship", null) + .WithMany("Documents") + .HasForeignKey("InternshipId") + .HasConstraintName("fk_document_internship_internship_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Edition", b => + { + b.HasOne("InternshipSystem.Core.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .HasConstraintName("fk_editions_course_course_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.Internship", b => + { + b.HasOne("InternshipSystem.Core.Edition", null) + .WithMany("Internships") + .HasForeignKey("EditionId") + .HasConstraintName("fk_internship_editions_edition_id"); + + 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_internship_internship_registration_internship_registration_"); + + b.HasOne("InternshipSystem.Core.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .HasConstraintName("fk_internship_report_report_id"); + + b.HasOne("InternshipSystem.Core.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .HasConstraintName("fk_internship_student_student_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b => + { + b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 => + { + b1.Property("InternshipProgramId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b1.Property("Email") + .HasColumnName("email") + .HasColumnType("text"); + + b1.Property("FirstName") + .HasColumnName("first_name") + .HasColumnType("text"); + + b1.Property("LastName") + .HasColumnName("last_name") + .HasColumnType("text"); + + b1.HasKey("InternshipProgramId") + .HasName("pk_internship_program"); + + b1.ToTable("internship_program"); + + b1.WithOwner() + .HasForeignKey("InternshipProgramId") + .HasConstraintName("fk_mentor_internship_program_internship_program_id"); + + b1.OwnsOne("InternshipSystem.Core.PhoneNumber", "PhoneNumber", b2 => + { + b2.Property("MentorInternshipProgramId") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + b2.HasKey("MentorInternshipProgramId") + .HasName("pk_internship_program"); + + b2.ToTable("internship_program"); + + b2.WithOwner() + .HasForeignKey("MentorInternshipProgramId") + .HasConstraintName("fk_phone_number_internship_program_mentor_internship_program_id"); + }); + }); + }); + + modelBuilder.Entity("InternshipSystem.Core.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_type_type_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b => + { + b.HasOne("InternshipSystem.Core.Edition", null) + .WithMany("AvailableSubjects") + .HasForeignKey("EditionId") + .HasConstraintName("fk_edition_subject_editions_edition_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId1") + .HasConstraintName("fk_edition_subject_editions_edition_id1"); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", null) + .WithMany() + .HasForeignKey("InternshipSubjectId") + .HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .HasConstraintName("fk_edition_subject_internship_subject_subject_id"); + }); + + modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b => + { + b.HasOne("InternshipSystem.Core.InternshipProgram", null) + .WithMany("ChosenSubjects") + .HasForeignKey("InternshipProgramId") + .HasConstraintName("fk_program_subject_internship_program_internship_program_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", null) + .WithMany() + .HasForeignKey("InternshipSubjectId") + .HasConstraintName("fk_program_subject_internship_subject_internship_subject_id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("InternshipSystem.Core.InternshipProgram", "Program") + .WithMany() + .HasForeignKey("ProgramId") + .HasConstraintName("fk_program_subject_internship_program_program_id"); + + b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .HasConstraintName("fk_program_subject_internship_subject_subject_id"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/InternshipSystem.Repository/Model/BranchOfficeReadModel.cs b/src/InternshipSystem.Repository/Model/BranchOfficeReadModel.cs deleted file mode 100644 index a3dbac1..0000000 --- a/src/InternshipSystem.Repository/Model/BranchOfficeReadModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -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; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/CompanyReadModel.cs b/src/InternshipSystem.Repository/Model/CompanyReadModel.cs deleted file mode 100644 index b800da9..0000000 --- a/src/InternshipSystem.Repository/Model/CompanyReadModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -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 Uri SiteAddress { get; set; } - public RangeOfActivity Range { get; set; } - public List Branches { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/EditionReadModel.cs b/src/InternshipSystem.Repository/Model/EditionReadModel.cs deleted file mode 100644 index cd221b0..0000000 --- a/src/InternshipSystem.Repository/Model/EditionReadModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -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 AvailableSubjects { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/EditionSubject.cs b/src/InternshipSystem.Repository/Model/EditionSubject.cs deleted file mode 100644 index 9141724..0000000 --- a/src/InternshipSystem.Repository/Model/EditionSubject.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace InternshipSystem.Repository -{ - public class EditionSubject - { - public long EditionId { get; set; } - public long InternshipId { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/InternshipProgramReadModel.cs b/src/InternshipSystem.Repository/Model/InternshipProgramReadModel.cs deleted file mode 100644 index aec7595..0000000 --- a/src/InternshipSystem.Repository/Model/InternshipProgramReadModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -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 ChosenSubjects { get; set; } - public DocumentState State { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/InternshipReadModel.cs b/src/InternshipSystem.Repository/Model/InternshipReadModel.cs deleted file mode 100644 index 9cec245..0000000 --- a/src/InternshipSystem.Repository/Model/InternshipReadModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -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 Approvals { get; set; } - public List Documents { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/InternshipRegistrationReadModel.cs b/src/InternshipSystem.Repository/Model/InternshipRegistrationReadModel.cs deleted file mode 100644 index 9f53e9c..0000000 --- a/src/InternshipSystem.Repository/Model/InternshipRegistrationReadModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -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; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/InternshipSubjectReadModel.cs b/src/InternshipSystem.Repository/Model/InternshipSubjectReadModel.cs deleted file mode 100644 index 9ed596c..0000000 --- a/src/InternshipSystem.Repository/Model/InternshipSubjectReadModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using InternshipSystem.Core; - -namespace InternshipSystem.Repository.Model -{ - public class InternshipSubjectReadModel - { - public long Id { get; set; } - - public string Description { get; set; } - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/Model/ProgramSubject.cs b/src/InternshipSystem.Repository/Model/ProgramSubject.cs deleted file mode 100644 index 256c3ca..0000000 --- a/src/InternshipSystem.Repository/Model/ProgramSubject.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace InternshipSystem.Repository.Model -{ - public class ProgramSubject - { - public long InternshipProgramId { get; set; } - public long InternshipSubjectId { get; set; } - } -} \ No newline at end of file