Jews are behind everything #27

Manually merged
maxchil merged 1 commits from fix/my_mind into master 2020-08-04 17:47:13 +02:00
29 changed files with 2353 additions and 551 deletions
Showing only changes of commit 526e84ecf8 - Show all commits

View File

@ -1,68 +1,68 @@
using System.Threading.Tasks; // using System.Threading.Tasks;
using InternshipSystem.Repository; // using InternshipSystem.Repository;
using Microsoft.AspNetCore.Mvc; // using Microsoft.AspNetCore.Mvc;
//
namespace InternshipSystem.Api.Controllers // 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<IActionResult> 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<IActionResult> FillCompaniesAsync()
// { // {
// [ApiController]
// [Route("admin")]
// public class AdminController : ControllerBase
// {
// public AdminController(DatabaseFiller fillerService)
// {
// FillerService = fillerService;
// }
//
// public DatabaseFiller FillerService { get; }
//
//
// [HttpPost("fill")]
// public async Task<IActionResult> Fill() {
// await FillerService.FillCompany(); // await FillerService.FillCompany();
// return Ok();
// }
//
// [HttpPost("fill/students")]
// public async Task<IActionResult> FillStudentsAsync() {
// await FillerService.FillStudents(); // await FillerService.FillStudents();
// return Ok();
// }
//
// [HttpPost("fill/subjects")]
// public async Task<IActionResult> FillSubjectsAsync()
// {
// await FillerService.FillSubjects(); // await FillerService.FillSubjects();
// return Ok();
// }
//
// [HttpPost("fill/internshiptypes")]
// public async Task<IActionResult> FillInternshipTypesAsync() {
// await FillerService.FillInternshipTypes(); // await FillerService.FillInternshipTypes();
// return Ok();
// }
//
// [HttpPost("fill/editions")]
// public async Task<IActionResult> FillEditionsAsync() {
// await FillerService.FillEditions(); // await FillerService.FillEditions();
// return Ok();
// }
//
// [HttpPost("fill/internships")]
// public async Task<IActionResult> FillInternShipsAsync() {
// await FillerService.FillInternShips(); // await FillerService.FillInternShips();
// return Ok(); // return Ok();
// } // }
} //
} // // [HttpPost("fill/companies")]
// // public async Task<IActionResult> FillCompaniesAsync()
// // {
// // await FillerService.FillCompany();
// // return Ok();
// // }
// //
// // [HttpPost("fill/students")]
// // public async Task<IActionResult> FillStudentsAsync() {
// // await FillerService.FillStudents();
// // return Ok();
// // }
// //
// // [HttpPost("fill/subjects")]
// // public async Task<IActionResult> FillSubjectsAsync()
// // {
// // await FillerService.FillSubjects();
// // return Ok();
// // }
// //
// // [HttpPost("fill/internshiptypes")]
// // public async Task<IActionResult> FillInternshipTypesAsync() {
// // await FillerService.FillInternshipTypes();
// // return Ok();
// // }
// //
// // [HttpPost("fill/editions")]
// // public async Task<IActionResult> FillEditionsAsync() {
// // await FillerService.FillEditions();
// // return Ok();
// // }
// //
// // [HttpPost("fill/internships")]
// // public async Task<IActionResult> FillInternShipsAsync() {
// // await FillerService.FillInternShips();
// // return Ok();
// // }
// }
// }

View File

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

View File

@ -1,16 +1,19 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
namespace InternshipSystem.Core namespace InternshipSystem.Core
{ {
public class Edition public class Edition
{ {
public long Id { get; private set; } public long Id { get; set; }
public DateTime EditionStart { get; private set; } public DateTime EditionStart { get; set; }
public DateTime EditionFinish { get; private set; } public DateTime EditionFinish { get; set; }
public DateTime ReportingStart { get; private set; } public DateTime ReportingStart { get; set; }
public Course Course { get; private set; } public Course Course { get; set; }
public IReadOnlyCollection<InternshipSubject> AvailableSubjects { get; private set; } public List<Internship> Internships { get; set; }
public List<EditionSubject> AvailableSubjects { get; set; }
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart) public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
{ {

View File

@ -1,4 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
namespace InternshipSystem.Core namespace InternshipSystem.Core
{ {
@ -6,7 +8,7 @@ namespace InternshipSystem.Core
{ {
public long Id { get; set; } public long Id { get; set; }
public Mentor Mentor { get; set; } public Mentor Mentor { get; set; }
public List<InternshipSubject> ChosenSubjects { get; set; }
public DocumentState State { get; set; } public DocumentState State { get; set; }
public List<ProgramSubject> ChosenSubjects { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core namespace InternshipSystem.Core
{ {

View File

@ -0,0 +1,9 @@
namespace InternshipSystem.Core.Entity.Internship
{
public class InternshipSubject
{
public long Id { get; set; }
public string Description { get; set; }
}
}

View File

@ -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 long Id { get; set; }
public string Type { get; set; } public string Type { get; set; }

View File

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

View File

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

View File

@ -1,6 +1,6 @@
namespace InternshipSystem.Core namespace InternshipSystem.Core
{ {
public struct BranchAddress public class BranchAddress
{ {
public string Street { get; set; } public string Street { get; set; }
public string Building { get; set; } public string Building { get; set; }

View File

@ -1,7 +0,0 @@
namespace InternshipSystem.Core
{
public struct InternshipSubject
{
public string Description { get; set; }
}
}

View File

@ -1,8 +0,0 @@
namespace InternshipSystem.Core
{
public struct InternshipType
{
public string Type { get; set; }
public string Description { get; set; }
}
}

View File

@ -1,6 +1,6 @@
namespace InternshipSystem.Core namespace InternshipSystem.Core
{ {
public struct Mentor public class Mentor
{ {
public string FirstName { get; set; } public string FirstName { get; set; }
public string LastName { get; set; } public string LastName { get; set; }

View File

@ -1,9 +1,13 @@
namespace InternshipSystem.Core namespace InternshipSystem.Core
{ {
public struct Nip public class Nip
{ {
private readonly string nip; private readonly string nip;
public Nip()
{
}
private Nip(string maybeNip) private Nip(string maybeNip)
{ {
nip = maybeNip; nip = maybeNip;

View File

@ -1,6 +1,22 @@
namespace InternshipSystem.Core 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);
}
} }

View File

@ -1,311 +1,313 @@
using System; // using System;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Collections.Immutable; // using System.Collections.Immutable;
using System.Linq; // using System.Linq;
using System.Threading.Tasks; // using System.Threading.Tasks;
using InternshipSystem.Core; // using InternshipSystem.Core;
using InternshipSystem.Repository.Model; // using InternshipSystem.Core.Entity.Internship;
using Microsoft.EntityFrameworkCore; // using InternshipSystem.Core.UglyOrmArtifacts;
// using InternshipSystem.Repository.Model;
namespace InternshipSystem.Repository // using Microsoft.EntityFrameworkCore;
{ //
public class DatabaseFiller // namespace InternshipSystem.Repository
{ // {
public DatabaseFiller(InternshipDbContext context) // public class DatabaseFiller
{ // {
Context = context; // public DatabaseFiller(InternshipDbContext context)
} // {
// Context = context;
public InternshipDbContext Context { get; } // }
//
public async Task FillCompany() // public InternshipDbContext Context { get; }
{ //
var companies = new List<CompanyReadModel> // public async Task FillCompany()
{ // {
new CompanyReadModel // var companies = new List<CompanyReadModel>
{ // {
Name = "Intel", // new CompanyReadModel
SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), // {
Nip = "9570752316", // Name = "Intel",
Range = RangeOfActivity.International, // SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
Branches = new List<BranchOfficeReadModel> // Nip = "9570752316",
{ // Range = RangeOfActivity.International,
new BranchOfficeReadModel // Branches = new List<BranchOfficeReadModel>
{ // {
City = "Gdańsk", // new BranchOfficeReadModel
Street = "ul. Słowackiego", // {
Building = "173", // City = "Gdańsk",
PostalCode = "80-298", // Street = "ul. Słowackiego",
Country = "Poland", // Building = "173",
}, // PostalCode = "80-298",
new BranchOfficeReadModel // Country = "Poland",
{ // },
City = "Gdańsk", // new BranchOfficeReadModel
Street = "Jana z Kolna", // {
Building = "11", // City = "Gdańsk",
PostalCode = "80-001", // Street = "Jana z Kolna",
Country = "Poland", // Building = "11",
}, // PostalCode = "80-001",
new BranchOfficeReadModel // Country = "Poland",
{ // },
City = "Boston", // new BranchOfficeReadModel
Street = "State St", // {
Building = "53", // City = "Boston",
PostalCode = "MA 02109", // Street = "State St",
Country = "Stany Zjednoczone", // Building = "53",
} // PostalCode = "MA 02109",
} // Country = "Stany Zjednoczone",
}, // }
new CompanyReadModel // }
{ // },
Name = "Asseco Poland", // new CompanyReadModel
SiteAddress = new Uri("http://pl.asseco.com"), // {
Nip = "5842068320", // Name = "Asseco Poland",
Range = RangeOfActivity.National, // SiteAddress = new Uri("http://pl.asseco.com"),
Branches = new List<BranchOfficeReadModel> // Nip = "5842068320",
{ // Range = RangeOfActivity.National,
new BranchOfficeReadModel // Branches = new List<BranchOfficeReadModel>
{ // {
City = "Gdańsk", // new BranchOfficeReadModel
Street = "ul. Podolska", // {
Building = "21", // City = "Gdańsk",
PostalCode = "81-321", // Street = "ul. Podolska",
Country = "Poland" // Building = "21",
}, // PostalCode = "81-321",
new BranchOfficeReadModel // Country = "Poland"
{ // },
City = "Wrocław", // new BranchOfficeReadModel
Street = "Traugutta", // {
Building = "1/7", // City = "Wrocław",
PostalCode = "50-449", // Street = "Traugutta",
Country = "Poland" // Building = "1/7",
} // PostalCode = "50-449",
} // Country = "Poland"
} // }
}; // }
await Context.Companies.AddRangeAsync(companies); // }
await Context.SaveChangesAsync(); // };
} // await Context.Companies.AddRangeAsync(companies);
// await Context.SaveChangesAsync();
public async Task FillStudents() // }
{ //
var interns = new List<Student> // public async Task FillStudents()
{ // {
new Student // var interns = new List<Student>
{ // {
FirstName = "Jan", // new Student
LastName = "Kowalski", // {
AlbumNumber = 123456, // FirstName = "Jan",
Email = "s123456@student.pg.edu.pl", // LastName = "Kowalski",
Semester = 4, // AlbumNumber = 123456,
}, // Email = "s123456@student.pg.edu.pl",
new Student // Semester = 4,
{ // },
FirstName = "Adam", // new Student
LastName = "Kołek", // {
AlbumNumber = 102137, // FirstName = "Adam",
Email = "s102137@student.pg.edu.pl", // LastName = "Kołek",
Semester = 6, // AlbumNumber = 102137,
} // Email = "s102137@student.pg.edu.pl",
}; // Semester = 6,
await Context.Students.AddRangeAsync(interns); // }
await Context.SaveChangesAsync(); // };
} // await Context.Students.AddRangeAsync(interns);
// await Context.SaveChangesAsync();
public async Task FillInternshipTypes() // }
{ //
var internshipTypes = new List<InternshipTypeReadModel> // public async Task FillInternshipTypes()
{ // {
new InternshipTypeReadModel // var internshipTypes = new List<InternshipType>
{ // {
Type = "FreeInternship", // new InternshipType
Description = "Praktyka bezpłatna", // {
}, // Type = "FreeInternship",
new InternshipTypeReadModel // Description = "Praktyka bezpłatna",
{ // },
Type = "GraduateInternship" // new InternshipType
}, // {
new InternshipTypeReadModel // Type = "GraduateInternship"
{ // },
Type = "FreeApprenticeship" // new InternshipType
}, // {
new InternshipTypeReadModel // Type = "FreeApprenticeship"
{ // },
Type = "PaidApprenticeship", // new InternshipType
Description = "np. przemysłowy" // {
}, // Type = "PaidApprenticeship",
new InternshipTypeReadModel // Description = "np. przemysłowy"
{ // },
Type = "ForeignInternship", // new InternshipType
Description = "np. IAESTE, ERASMUS" // {
}, // Type = "ForeignInternship",
new InternshipTypeReadModel // Description = "np. IAESTE, ERASMUS"
{ // },
Type = "UOP" // new InternshipType
}, // {
new InternshipTypeReadModel // Type = "UOP"
{ // },
Type = "UD" // new InternshipType
}, // {
new InternshipTypeReadModel // Type = "UD"
{ // },
Type = "UZ" // new InternshipType
}, // {
new InternshipTypeReadModel // Type = "UZ"
{ // },
Type = "Other", // new InternshipType
Description = "Należy wprowadzić samodzielnie" // {
} // Type = "Other",
}; // Description = "Należy wprowadzić samodzielnie"
await Context.InternshipTypes.AddRangeAsync(internshipTypes); // }
await Context.SaveChangesAsync(); // };
} // await Context.InternshipTypes.AddRangeAsync(internshipTypes);
// await Context.SaveChangesAsync();
public async Task FillSubjects() // }
{ //
var subjects = new List<InternshipSubjectReadModel> // public async Task FillSubjects()
{ // {
new InternshipSubjectReadModel // var subjects = new List<InternshipSubject>
{ // {
Description = "Modelowanie baz danych" // new InternshipSubject
}, // {
new InternshipSubjectReadModel // Description = "Modelowanie baz danych"
{ // },
Description = "Oprogramowywanie kart graficznych" // new InternshipSubject
}, // {
new InternshipSubjectReadModel // Description = "Oprogramowywanie kart graficznych"
{ // },
Description = "Projektowanie UI" // new InternshipSubject
} // {
}; // Description = "Projektowanie UI"
await Context.Subjects.AddRangeAsync(subjects); // }
await Context.SaveChangesAsync(); // };
} // await Context.Subjects.AddRangeAsync(subjects);
// await Context.SaveChangesAsync();
public async Task FillEditions() // }
{ //
var editions = new List<EditionReadModel> // public async Task FillEditions()
{ // {
new EditionReadModel // var editions = new List<EditionReadModel>
{ // {
EditionStart = new DateTime(2000, 5, 10), // new EditionReadModel
EditionFinish = new DateTime(2000, 11, 10), // {
ReportingStart = new DateTime(2000, 9, 30), // EditionStart = new DateTime(2000, 5, 10),
AvailableSubjects = new List<EditionSubject> // EditionFinish = new DateTime(2000, 11, 10),
{ // ReportingStart = new DateTime(2000, 9, 30),
new EditionSubject // AvailableSubjects = new List<EditionSubject>
{ // {
InternshipId = Context.Subjects // new EditionSubject
.First(i => i.Description.Equals("Modelowanie baz danych")) // {
.Id, // InternshipId = Context.Subjects
}, // .First(i => i.Description.Equals("Modelowanie baz danych"))
new EditionSubject // .Id,
{ // },
InternshipId = Context.Subjects // new EditionSubject
.First(i => i.Description.Equals("Oprogramowywanie kart graficznych")) // {
.Id // InternshipId = Context.Subjects
}, // .First(i => i.Description.Equals("Oprogramowywanie kart graficznych"))
new EditionSubject // .Id
{ // },
InternshipId = Context.Subjects // new EditionSubject
.First(i => i.Description.Equals("Projektowanie UI")) // {
.Id // InternshipId = Context.Subjects
} // .First(i => i.Description.Equals("Projektowanie UI"))
}.ToImmutableList(), // .Id
Course = new Course // }
{ // }.ToImmutableList(),
Name = "Informatyka", // Course = new Course
} // {
} // Name = "Informatyka",
}; // }
await Context.Editions.AddRangeAsync(editions); // }
await Context.SaveChangesAsync(); // };
} // await Context.Editions.AddRangeAsync(editions);
// await Context.SaveChangesAsync();
public async Task FillInternShips() // }
{ //
var intenrships = new List<InternshipReadModel> // public async Task FillInternShips()
{ // {
new InternshipReadModel // var intenrships = new List<InternshipReadModel>
{ // {
Student = Context.Students.First(i => i.AlbumNumber.Equals(123456)), // new InternshipReadModel
InternshipRegistration = new InternshipRegistrationReadModel() // {
{ // Student = Context.Students.First(i => i.AlbumNumber.Equals(123456)),
Company = Context.Companies.First(c => c.Nip.Equals("9570752316")), //Intel // InternshipRegistration = new InternshipRegistrationReadModel()
Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")), // {
Start = new DateTime(2000, 7, 1), // Company = Context.Companies.First(c => c.Nip.Equals("9570752316")), //Intel
End = new DateTime(2000, 8, 30), // Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
State = DocumentState.Submitted, // Start = new DateTime(2000, 7, 1),
BranchAddress = // End = new DateTime(2000, 8, 30),
Context.Companies // State = DocumentState.Submitted,
.Include(c => c.Branches) // BranchAddress =
.First(c => c.Nip.Equals("9570752316")) // Context.Companies
.Branches // .Include(c => c.Branches)
.First(), // .First(c => c.Nip.Equals("9570752316"))
}, // .Branches
InternshipProgram = new InternshipProgramReadModel() // .First(),
{ // },
FirstName = "Horacy", // InternshipProgram = new InternshipProgramReadModel()
LastName = "Wościcki", // {
Email = "howos@intel.com", // FirstName = "Horacy",
PhoneNumber = "605-555-555", // LastName = "Wościcki",
ChosenSubjects = new List<ProgramSubject> // Email = "howos@intel.com",
{ // PhoneNumber = "605-555-555",
new ProgramSubject // ChosenSubjects = new List<ProgramSubject>
{ // {
InternshipSubjectId = // new ProgramSubject
Context.Subjects // {
.First(s => s.Description.Equals("Projektowanie UI")) // InternshipSubjectId =
.Id // Context.Subjects
}, // .First(s => s.Description.Equals("Projektowanie UI"))
new ProgramSubject // .Id
{ // },
InternshipSubjectId = // new ProgramSubject
Context.Subjects // {
.First(s => s.Description.Equals("Oprogramowywanie kart graficznych")) // InternshipSubjectId =
.Id // Context.Subjects
} // .First(s => s.Description.Equals("Oprogramowywanie kart graficznych"))
} // .Id
}, // }
}, // }
new InternshipReadModel // },
{ // },
Student = Context.Students.First(i => i.AlbumNumber == 102137), // new InternshipReadModel
InternshipRegistration = new InternshipRegistrationReadModel() // {
{ // Student = Context.Students.First(i => i.AlbumNumber == 102137),
Company = Context.Companies.First(c => c.Nip.Equals("5842068320")), //Asseco // InternshipRegistration = new InternshipRegistrationReadModel()
Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")), // {
Start = new DateTime(2000, 7, 1), // Company = Context.Companies.First(c => c.Nip.Equals("5842068320")), //Asseco
End = new DateTime(2000, 8, 30), // Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
State = DocumentState.Submitted, // Start = new DateTime(2000, 7, 1),
BranchAddress = // End = new DateTime(2000, 8, 30),
Context.Companies // State = DocumentState.Submitted,
.Include(c => c.Branches) // BranchAddress =
.First(c => c.Nip.Equals("5842068320")) // Context.Companies
.Branches // .Include(c => c.Branches)
.First(), // .First(c => c.Nip.Equals("5842068320"))
}, // .Branches
InternshipProgram = new InternshipProgramReadModel() // .First(),
{ // },
FirstName = "Henryk", // InternshipProgram = new InternshipProgramReadModel()
LastName = "Polaciński", // {
Email = "hepol@asseco.pl", // FirstName = "Henryk",
PhoneNumber = "555-525-545", // LastName = "Polaciński",
ChosenSubjects = new List<ProgramSubject> // Email = "hepol@asseco.pl",
{ // PhoneNumber = "555-525-545",
new ProgramSubject // ChosenSubjects = new List<ProgramSubject>
{ // {
InternshipSubjectId = // new ProgramSubject
Context.Subjects // {
.First(s => s.Description.Equals("Modelowanie baz danych")) // InternshipSubjectId =
.Id // Context.Subjects
} // .First(s => s.Description.Equals("Modelowanie baz danych"))
}, // .Id
}, // }
}, // },
}; // },
await Context.Internships.AddRangeAsync(intenrships); // },
await Context.SaveChangesAsync(); // };
} // await Context.Internships.AddRangeAsync(intenrships);
} // await Context.SaveChangesAsync();
} // }
// }
// }

View File

@ -1,24 +1,14 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using InternshipSystem.Core; using InternshipSystem.Core;
using InternshipSystem.Repository.Model; using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
namespace InternshipSystem.Repository namespace InternshipSystem.Repository
{ {
public class InternshipDbContext : DbContext public class InternshipDbContext : DbContext
{ {
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<InternshipSubjectReadModel> Subjects { get; set; }
public DbSet<EditionReadModel> Editions { get; set; }
public DbSet<Student> Students { get; set; }
public DbSet<Approval> Approvals { 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)
@ -31,18 +21,28 @@ namespace InternshipSystem.Repository
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<BranchOffice>()
.OwnsOne(bo => bo.Address);
modelBuilder.Entity<InternshipProgram>()
.OwnsOne(ip => ip.Mentor)
.OwnsOne(m => m.PhoneNumber);
modelBuilder.Entity<Company>()
.OwnsOne(c => c.Nip);
modelBuilder.Entity<ProgramSubject>(builder => modelBuilder.Entity<ProgramSubject>(builder =>
{ {
builder builder
.HasKey(subject => new { subject.InternshipProgramId, subject.InternshipSubjectId }); .HasKey(subject => new { subject.InternshipProgramId, subject.InternshipSubjectId });
builder builder
.HasOne<InternshipProgramReadModel>() .HasOne<InternshipProgram>()
.WithMany(model => model.ChosenSubjects) .WithMany(model => model.ChosenSubjects)
.HasForeignKey(subject => subject.InternshipProgramId); .HasForeignKey(subject => subject.InternshipProgramId);
builder builder
.HasOne<InternshipSubjectReadModel>() .HasOne<InternshipSubject>()
.WithMany() .WithMany()
.HasForeignKey(subject => subject.InternshipSubjectId); .HasForeignKey(subject => subject.InternshipSubjectId);
}); });
@ -50,17 +50,17 @@ namespace InternshipSystem.Repository
modelBuilder.Entity<EditionSubject>(builder => modelBuilder.Entity<EditionSubject>(builder =>
{ {
builder builder
.HasKey(subject => new { subject.EditionId, subject.InternshipId}); .HasKey(subject => new { subject.EditionId, subject.InternshipSubjectId});
builder builder
.HasOne<EditionReadModel>() .HasOne<Edition>()
.WithMany(model => model.AvailableSubjects) .WithMany(model => model.AvailableSubjects)
.HasForeignKey(p => p.EditionId); .HasForeignKey(p => p.EditionId);
builder builder
.HasOne<InternshipSubjectReadModel>() .HasOne<InternshipSubject>()
.WithMany() .WithMany()
.HasForeignKey(subject => subject.InternshipId); .HasForeignKey(subject => subject.InternshipSubjectId);
}); });
} }
} }

View File

@ -0,0 +1,692 @@
// <auto-generated />
using System;
using InternshipSystem.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
[Migration("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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<byte[]>("Scan")
.HasColumnName("scan")
.HasColumnType("bytea");
b.Property<int>("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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_companies");
b.ToTable("companies");
});
modelBuilder.Entity("InternshipSystem.Core.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_course");
b.ToTable("course");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_document");
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
b.Property<DateTime>("EditionFinish")
.HasColumnName("edition_finish")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("EditionStart")
.HasColumnName("edition_start")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("ReportingStart")
.HasColumnName("reporting_start")
.HasColumnType("timestamp without time zone");
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("CourseId")
.HasName("ix_editions_course_id");
b.ToTable("editions");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_subject");
b.ToTable("internship_subject");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnName("type")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_type");
b.ToTable("internship_type");
});
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("bigint");
b.Property<long?>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_internship_program");
b.ToTable("internship_program");
});
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("BranchAddressId")
.HasColumnName("branch_address_id")
.HasColumnType("bigint");
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<DateTime>("End")
.HasColumnName("end")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("Start")
.HasColumnName("start")
.HasColumnType("timestamp without time zone");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<long?>("TypeId")
.HasColumnName("type_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internship_registration");
b.HasIndex("BranchAddressId")
.HasName("ix_internship_registration_branch_address_id");
b.HasIndex("CompanyId")
.HasName("ix_internship_registration_company_id");
b.HasIndex("TypeId")
.HasName("ix_internship_registration_type_id");
b.ToTable("internship_registration");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_report");
b.ToTable("report");
});
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("AlbumNumber")
.HasColumnName("album_number")
.HasColumnType("integer");
b.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b.Property<int>("Semester")
.HasColumnName("semester")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_student");
b.ToTable("student");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.Property<long>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.Property<long?>("EditionId1")
.HasColumnName("edition_id1")
.HasColumnType("bigint");
b.Property<long?>("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<long>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.Property<long?>("ProgramId")
.HasColumnName("program_id")
.HasColumnType("bigint");
b.Property<long?>("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<long>("BranchOfficeId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Building")
.HasColumnName("building")
.HasColumnType("text");
b1.Property<string>("City")
.HasColumnName("city")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnName("country")
.HasColumnType("text");
b1.Property<string>("PostalCode")
.HasColumnName("postal_code")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnName("street")
.HasColumnType("text");
b1.HasKey("BranchOfficeId")
.HasName("pk_branch_office");
b1.ToTable("branch_office");
b1.WithOwner()
.HasForeignKey("BranchOfficeId")
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
{
b.OwnsOne("InternshipSystem.Core.Nip", "Nip", b1 =>
{
b1.Property<long>("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<long>("InternshipProgramId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b1.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b1.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b1.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<long>("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
}
}
}

View File

@ -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<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(nullable: true),
range = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_companies", x => x.id);
});
migrationBuilder.CreateTable(
name: "course",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_course", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_program",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
first_name = table.Column<string>(nullable: true),
last_name = table.Column<string>(nullable: true),
email = table.Column<string>(nullable: true),
state = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_program", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_subject",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_subject", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_type",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
type = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_type", x => x.id);
});
migrationBuilder.CreateTable(
name: "report",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
state = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_report", x => x.id);
});
migrationBuilder.CreateTable(
name: "student",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
album_number = table.Column<int>(nullable: false),
first_name = table.Column<string>(nullable: true),
last_name = table.Column<string>(nullable: true),
email = table.Column<string>(nullable: true),
semester = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_student", x => x.id);
});
migrationBuilder.CreateTable(
name: "branch_office",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
street = table.Column<string>(nullable: true),
building = table.Column<string>(nullable: true),
city = table.Column<string>(nullable: true),
postal_code = table.Column<string>(nullable: true),
country = table.Column<string>(nullable: true),
company_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_branch_office", x => x.id);
table.ForeignKey(
name: "fk_branch_office_companies_company_id",
column: x => x.company_id,
principalTable: "companies",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "editions",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
edition_start = table.Column<DateTime>(nullable: false),
edition_finish = table.Column<DateTime>(nullable: false),
reporting_start = table.Column<DateTime>(nullable: false),
course_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_editions", x => x.id);
table.ForeignKey(
name: "fk_editions_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<long>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false),
program_id = table.Column<long>(nullable: true),
subject_id = table.Column<long>(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<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
company_id = table.Column<long>(nullable: true),
branch_address_id = table.Column<long>(nullable: true),
start = table.Column<DateTime>(nullable: false),
end = table.Column<DateTime>(nullable: false),
type_id = table.Column<long>(nullable: true),
state = table.Column<int>(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<long>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false),
edition_id1 = table.Column<long>(nullable: true),
subject_id = table.Column<long>(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<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
student_id = table.Column<long>(nullable: true),
internship_registration_id = table.Column<long>(nullable: true),
internship_program_id = table.Column<long>(nullable: true),
report_id = table.Column<long>(nullable: true),
edition_id = table.Column<long>(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<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
scan = table.Column<byte[]>(nullable: true),
state = table.Column<int>(nullable: false),
internship_id = table.Column<long>(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<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true),
state = table.Column<int>(nullable: false),
internship_id = table.Column<long>(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");
}
}
}

View File

@ -0,0 +1,690 @@
// <auto-generated />
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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<byte[]>("Scan")
.HasColumnName("scan")
.HasColumnType("bytea");
b.Property<int>("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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_companies");
b.ToTable("companies");
});
modelBuilder.Entity("InternshipSystem.Core.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_course");
b.ToTable("course");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_document");
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
b.Property<DateTime>("EditionFinish")
.HasColumnName("edition_finish")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("EditionStart")
.HasColumnName("edition_start")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("ReportingStart")
.HasColumnName("reporting_start")
.HasColumnType("timestamp without time zone");
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("CourseId")
.HasName("ix_editions_course_id");
b.ToTable("editions");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_subject");
b.ToTable("internship_subject");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnName("type")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_type");
b.ToTable("internship_type");
});
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("bigint");
b.Property<long?>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_internship_program");
b.ToTable("internship_program");
});
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("BranchAddressId")
.HasColumnName("branch_address_id")
.HasColumnType("bigint");
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<DateTime>("End")
.HasColumnName("end")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("Start")
.HasColumnName("start")
.HasColumnType("timestamp without time zone");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<long?>("TypeId")
.HasColumnName("type_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internship_registration");
b.HasIndex("BranchAddressId")
.HasName("ix_internship_registration_branch_address_id");
b.HasIndex("CompanyId")
.HasName("ix_internship_registration_company_id");
b.HasIndex("TypeId")
.HasName("ix_internship_registration_type_id");
b.ToTable("internship_registration");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_report");
b.ToTable("report");
});
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("AlbumNumber")
.HasColumnName("album_number")
.HasColumnType("integer");
b.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b.Property<int>("Semester")
.HasColumnName("semester")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_student");
b.ToTable("student");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.Property<long>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.Property<long?>("EditionId1")
.HasColumnName("edition_id1")
.HasColumnType("bigint");
b.Property<long?>("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<long>("InternshipProgramId")
.HasColumnName("internship_program_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.Property<long?>("ProgramId")
.HasColumnName("program_id")
.HasColumnType("bigint");
b.Property<long?>("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<long>("BranchOfficeId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Building")
.HasColumnName("building")
.HasColumnType("text");
b1.Property<string>("City")
.HasColumnName("city")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnName("country")
.HasColumnType("text");
b1.Property<string>("PostalCode")
.HasColumnName("postal_code")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnName("street")
.HasColumnType("text");
b1.HasKey("BranchOfficeId")
.HasName("pk_branch_office");
b1.ToTable("branch_office");
b1.WithOwner()
.HasForeignKey("BranchOfficeId")
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
{
b.OwnsOne("InternshipSystem.Core.Nip", "Nip", b1 =>
{
b1.Property<long>("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<long>("InternshipProgramId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b1.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b1.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b1.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<long>("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
}
}
}

View File

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

View File

@ -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<BranchOfficeReadModel> Branches { get; set; }
}
}

View File

@ -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<EditionSubject> AvailableSubjects { get; set; }
}
}

View File

@ -1,8 +0,0 @@
namespace InternshipSystem.Repository
{
public class EditionSubject
{
public long EditionId { get; set; }
public long InternshipId { get; set; }
}
}

View File

@ -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<ProgramSubject> ChosenSubjects { get; set; }
public DocumentState State { get; set; }
}
}

View File

@ -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<Approval> Approvals { get; set; }
public List<Document> Documents { get; set; }
}
}

View File

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

View File

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

View File

@ -1,8 +0,0 @@
namespace InternshipSystem.Repository.Model
{
public class ProgramSubject
{
public long InternshipProgramId { get; set; }
public long InternshipSubjectId { get; set; }
}
}