Separate Mentor and first full version of DatabaseFiller

This commit is contained in:
mborzyszkowski 2020-07-14 18:34:04 +02:00
parent 9e9b12cdd6
commit 3e70d40ec8
5 changed files with 146 additions and 89 deletions

View File

@ -15,6 +15,17 @@ namespace Internship.Api.Controller
public DatabaseFiller FillerService { get; }
[HttpPost("fill")]
public async Task<IActionResult> Fill() {
await FillerService.FillCompany();
await FillerService.FillInterns();
await FillerService.FillInternshipTypes();
await FillerService.FillEditions();
await FillerService.FillInternShips();
return Ok();
}
[HttpPost("fill/companies")]
public async Task<IActionResult> FillCompaniesAsync()
{
@ -32,19 +43,18 @@ namespace Internship.Api.Controller
public async Task<IActionResult> FillInternshipTypesAsync() {
await FillerService.FillInternshipTypes();
return Ok();
}
}
// TODO:
// [HttpPost("fill/editions")]
// public async Task<IActionResult> FillEditionsAsync() {
// await FillerService.FillEditions();
// 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

@ -4,9 +4,9 @@ namespace InternshipSystem.Core
{
public class DeanAcceptance
{
public DateTime AcceptanceDate { get; set; }
public DateTime? AcceptanceDate { get; set; }
public bool IsDeansAcceptanceRequired { get; set; }
public DeanAcceptanceReason Reason { get; set; }
public DeanAcceptanceReason? Reason { get; set; }
}
public enum DeanAcceptanceReason

View File

@ -1,6 +1,7 @@
namespace InternshipSystem.Core
{
public class Mentor {
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public string Email { get; set; }

View File

@ -25,11 +25,11 @@ namespace InternshipSystem.Repository
SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
Nip = "9570752316",
Range = RangeOfActivities.International,
Branches = new List<BranchOffice>()
Branches = new List<BranchOffice>
{
new BranchOffice()
new BranchOffice
{
Address = new Address()
Address = new Address
{
City = "Gdańsk",
Street = "ul. Słowackiego",
@ -38,9 +38,9 @@ namespace InternshipSystem.Repository
Country = "Poland"
}
},
new BranchOffice()
new BranchOffice
{
Address = new Address()
Address = new Address
{
City = "Gdańsk",
Street = "Jana z Kolna",
@ -49,9 +49,9 @@ namespace InternshipSystem.Repository
Country = "Poland"
}
},
new BranchOffice()
new BranchOffice
{
Address = new Address()
Address = new Address
{
City = "Boston",
Street = "State St",
@ -108,10 +108,30 @@ namespace InternshipSystem.Repository
Surname = "Kowalski",
AlbumNumber = "123456",
Email = "s123456@student.pg.edu.pl",
Semester = 4,
Course = new Course
{
Name = "Informatyka",
DesiredSemesters = new List<int> { 4, 6 }
DesiredSemesters = new List<int> { 4, 6 },
ProgramEntries = new List<InternshipProgramEntry>
{
new InternshipProgramEntry
{
Description = "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych."
},
new InternshipProgramEntry
{
Description = "Implementacja polityki bezpieczeństwa informacji w firmie lub instytucji, instalacja ochrony antywirusowej, konfiguracja zapór ogniowych."
},
new InternshipProgramEntry
{
Description = "Instalacja, konfiguracja i administracja oprogramowania, w szczególnościsystemów operacyjnychiserwerów aplikacji."
},
new InternshipProgramEntry
{
Description = "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań."
}
}
}
},
new Intern {
@ -119,10 +139,30 @@ namespace InternshipSystem.Repository
Surname = "Kołek",
AlbumNumber = "102137",
Email = "s102137@student.pg.edu.pl",
Semester = 6,
Course = new Course
{
Name = "Robotyka",
DesiredSemesters = new List<int> { 6 }
DesiredSemesters = new List<int> { 6 },
ProgramEntries = new List<InternshipProgramEntry>
{
new InternshipProgramEntry
{
Description = "Testowanie oprogramowania, także z wykorzystaniem narzędzi do testowania automatycznego."
},
new InternshipProgramEntry
{
Description = "Wykorzystanie otwartych komponentów programowych z uwzględnieniem prawnych zależności pomiędzy nimi a produktem wynikowym."
},
new InternshipProgramEntry
{
Description = "Projektowanie i implementacja baz danych oraz badanie ich wydajności."
},
new InternshipProgramEntry
{
Description = "Projektowanie i prototypowaniezaawansowanychinterfejsów użytkownika."
}
}
}
}
};
@ -178,64 +218,45 @@ namespace InternshipSystem.Repository
await Context.SaveChangesAsync();
}
// TODO: rewrite later
// public async Task FillEditions() {
// var editions = new List<Edition>
// {
// new Edition
// {
// StartDate = new DateTime(2000, 5, 10),
// EndDate = new DateTime(2000, 11, 10),
// IPPDeadlineDate = new DateTime(2000, 9, 30),
// Subjects = new List<InternshipProgramSubject>
// {
// new InternshipProgramSubject
// {
// Course = new Course
// {
// Name = "Informatyka"
// }
// },
// new InternshipProgramSubject
// {
// Course = new Course
// {
// Name = "Budowanie UI"
// }
// },
// new InternshipProgramSubject
// {
// Course = new Course
// {
// Name = "Budowanie Back End"
// }
// }
// }
// }
// };
// Context.Editions.AddRange(editions);
// await Context.SaveChangesAsync();
// }
public async Task FillEditions() {
var editions = new List<Edition>
{
new Edition
{
StartDate = new DateTime(2000, 5, 10),
EndDate = new DateTime(2000, 11, 10),
IPPDeadlineDate = new DateTime(2000, 9, 30),
Subjects = new List<InternshipProgramEntry>
{
Context.InternshipProgramEntries
.Where(i => i.Description == "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych.")
.First(),
Context.InternshipProgramEntries
.Where(i => i.Description == "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań.")
.First()
}
}
};
Context.Editions.AddRange(editions);
await Context.SaveChangesAsync();
}
public async Task FillInternShips() {
var edition = Context.Editions.First();
var intenrships = new List<Internship>
{
new Internship
{
Intern = Context.Interns.Where(i => i.AlbumNumber == "123456").Single(),
Edition = null, //TODO: Context.Editions.Where(e => e.StartDate.Equals(new DateTime(2000, 5, 10))).Single(),
BranchOffice = new BranchOffice()
{
Address = new Address()
{
City = "Gdańsk",
Street = "ul. Słowackiego",
Building = "173",
PostalCode = "80-298",
Country = "Poland"
}
},
Type = Context.InternshipTypes.Where(t => t.Type == "UOP").Single(),
Intern = Context.Interns.Where(i => i.AlbumNumber == "123456").First(),
Edition = edition,
BranchOffice =
Context.Companies
.Where(c => c.Nip == "9570752316") //Intel
.First()
.Branches
.First(),
Type = Context.InternshipTypes.Where(t => t.Type == "UOP").First(),
StartDate = new DateTime(2000, 7, 1),
EndDate = new DateTime(2000, 8, 30),
IsAccepted = false,
@ -249,25 +270,49 @@ namespace InternshipSystem.Repository
{
InsuranceDeliveryDate = new DateTime(2000, 6, 29),
IsInsuranceRequired = true
},
InternshipLengthInWeeks = 9,
},
LengthInWeeks = 9,
Grade = 0,
Program = new List<InternshipProgramSubject>
Program = new List<InternshipProgramEntry>
{
new InternshipProgramSubject
{
Course = new Course
{
Name = "Bazy Danych"
}
},
new InternshipProgramSubject
{
Course = new Course
{
Name = "Design UI"
}
}
edition.Subjects.First()
},
Mentor = new Mentor
{
Name = "Horacy",
Surname = "Wościcki",
Email = "howos@intel.com",
Phone = "605-555-555"
}
},
new Internship
{
Intern = Context.Interns.Where(i => i.AlbumNumber == "102137").First(),
Edition = edition,
BranchOffice =
Context.Companies
.Where(c => c.Nip == "5842068320") //Asseco
.First()
.Branches
.First(),
Type = Context.InternshipTypes.Where(t => t.Type == "UZ").First(),
StartDate = new DateTime(2000, 7, 1),
EndDate = new DateTime(2000, 8, 30),
IsAccepted = false,
DeanAcceptance = new DeanAcceptance
{
IsDeansAcceptanceRequired = false
},
Insurance = new Insurance
{
InsuranceDeliveryDate = new DateTime(2000, 6, 29),
IsInsuranceRequired = true
},
LengthInWeeks = 9,
Grade = 0,
Program = new List<InternshipProgramEntry>
{
edition.Subjects.First()
},
Mentor = new Mentor
{

View File

@ -11,6 +11,8 @@ namespace InternshipSystem.Repository
public DbSet<Report> Reports { get; set; }
public DbSet<Intern> Interns { get; set; }
public DbSet<InternshipType> InternshipTypes { get; set; }
public DbSet<Mentor> Mentors { get; set; }
public DbSet<InternshipProgramEntry> InternshipProgramEntries { get; set; }
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
: base(options)
{
@ -25,7 +27,6 @@ namespace InternshipSystem.Repository
.Entity<Internship>(ie => {
ie.OwnsOne(i => i.DeanAcceptance);
ie.OwnsOne(i => i.Insurance);
ie.OwnsOne(i => i.Mentor);
});
modelBuilder