migrationVOL2 #26

Manually merged
Zonar merged 2 commits from migrationVOL2 into master 2020-08-04 16:51:03 +02:00
4 changed files with 383 additions and 392 deletions

View File

@ -1,31 +1,32 @@
// using System.Threading.Tasks; using System.Threading.Tasks;
// using InternshipSystem.Repository; using InternshipSystem.Repository;
// using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
//
// namespace Internship.Api.Controller namespace InternshipSystem.Api.Controllers
// { {
// [ApiController] [ApiController]
// [Route("admin")] [Route("admin")]
// public class AdminController : ControllerBase public class AdminController : ControllerBase
// { {
// public AdminController(DatabaseFiller fillerService) public AdminController(DatabaseFiller fillerService)
// { {
// FillerService = fillerService; FillerService = fillerService;
// } }
//
// public DatabaseFiller FillerService { get; } public DatabaseFiller FillerService { get; }
//
//
// [HttpPost("fill")] [HttpPost("fill")]
// public async Task<IActionResult> Fill() { public async Task<IActionResult> Fill() {
// await FillerService.FillCompany(); await FillerService.FillCompany();
// await FillerService.FillInterns(); await FillerService.FillStudents();
// await FillerService.FillInternshipTypes(); await FillerService.FillSubjects();
// await FillerService.FillEditions(); await FillerService.FillInternshipTypes();
// await FillerService.FillInternShips(); await FillerService.FillEditions();
// return Ok(); await FillerService.FillInternShips();
// } return Ok();
// }
// [HttpPost("fill/companies")] // [HttpPost("fill/companies")]
// public async Task<IActionResult> FillCompaniesAsync() // public async Task<IActionResult> FillCompaniesAsync()
// { // {
@ -33,9 +34,16 @@
// return Ok(); // return Ok();
// } // }
// //
// [HttpPost("fill/interns")] // [HttpPost("fill/students")]
// public async Task<IActionResult> FillInternsAsync() { // public async Task<IActionResult> FillStudentsAsync() {
// await FillerService.FillInterns(); // await FillerService.FillStudents();
// return Ok();
// }
//
// [HttpPost("fill/subjects")]
// public async Task<IActionResult> FillSubjectsAsync()
// {
// await FillerService.FillSubjects();
// return Ok(); // return Ok();
// } // }
// //
@ -56,5 +64,5 @@
// await FillerService.FillInternShips(); // await FillerService.FillInternShips();
// return Ok(); // 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,330 +1,311 @@
// using System; using System;
// using System.Collections.Generic; using System.Collections.Generic;
// using System.Linq; using System.Collections.Immutable;
// using System.Threading.Tasks; using System.Linq;
// using InternshipSystem.Core; using System.Threading.Tasks;
// using InternshipSystem.Core;
// namespace InternshipSystem.Repository using InternshipSystem.Repository.Model;
// { using Microsoft.EntityFrameworkCore;
// public class DatabaseFiller
// { namespace InternshipSystem.Repository
// public DatabaseFiller(InternshipDbContext context) {
// { public class DatabaseFiller
// Context = context; {
// } public DatabaseFiller(InternshipDbContext context)
// {
// public InternshipDbContext Context { get; } Context = context;
// }
// public async Task FillCompany()
// { public InternshipDbContext Context { get; }
// var companies = new List<Company>
// { public async Task FillCompany()
// new Company {
// { var companies = new List<CompanyReadModel>
// Name = "Intel", {
// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), new CompanyReadModel
// Nip = "9570752316", {
// Range = RangeOfActivities.International, Name = "Intel",
// Branches = new List<BranchOffice> SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
// { Nip = "9570752316",
// new BranchOffice Range = RangeOfActivity.International,
// { Branches = new List<BranchOfficeReadModel>
// Address = new Address {
// { new BranchOfficeReadModel
// City = "Gdańsk", {
// Street = "ul. Słowackiego", City = "Gdańsk",
// Building = "173", Street = "ul. Słowackiego",
// PostalCode = "80-298", Building = "173",
// Country = "Poland" PostalCode = "80-298",
// } Country = "Poland",
// }, },
// new BranchOffice new BranchOfficeReadModel
// { {
// Address = new Address City = "Gdańsk",
// { Street = "Jana z Kolna",
// City = "Gdańsk", Building = "11",
// Street = "Jana z Kolna", PostalCode = "80-001",
// Building = "11", Country = "Poland",
// PostalCode = "80-001", },
// Country = "Poland" new BranchOfficeReadModel
// } {
// }, City = "Boston",
// new BranchOffice Street = "State St",
// { Building = "53",
// Address = new Address PostalCode = "MA 02109",
// { Country = "Stany Zjednoczone",
// City = "Boston", }
// Street = "State St", }
// Building = "53", },
// PostalCode = "MA 02109", new CompanyReadModel
// Country = "Stany Zjednoczone" {
// } Name = "Asseco Poland",
// } SiteAddress = new Uri("http://pl.asseco.com"),
// } Nip = "5842068320",
// }, Range = RangeOfActivity.National,
// new Company Branches = new List<BranchOfficeReadModel>
// { {
// Name = "Asseco Poland", new BranchOfficeReadModel
// SiteAddress = new Uri("http://pl.asseco.com"), {
// Nip = "5842068320", City = "Gdańsk",
// Range = RangeOfActivities.National, Street = "ul. Podolska",
// Branches = new List<BranchOffice> Building = "21",
// { PostalCode = "81-321",
// new BranchOffice Country = "Poland"
// { },
// Address = new Address new BranchOfficeReadModel
// { {
// City = "Gdańsk", City = "Wrocław",
// Street = "ul. Podolska", Street = "Traugutta",
// Building = "21", Building = "1/7",
// PostalCode = "81-321", PostalCode = "50-449",
// Country = "Poland" Country = "Poland"
// } }
// }, }
// new BranchOffice }
// { };
// Address = new Address await Context.Companies.AddRangeAsync(companies);
// { await Context.SaveChangesAsync();
// City = "Wrocław", }
// Street = "Traugutta",
// Building = "1/7", public async Task FillStudents()
// PostalCode = "50-449", {
// Country = "Poland" var interns = new List<Student>
// } {
// } new Student
// } {
// } FirstName = "Jan",
// }; LastName = "Kowalski",
// Context.Companies.AddRange(companies); AlbumNumber = 123456,
// await Context.SaveChangesAsync(); Email = "s123456@student.pg.edu.pl",
// } Semester = 4,
// },
// public async Task FillInterns() new Student
// { {
// var interns = new List<Intern> FirstName = "Adam",
// { LastName = "Kołek",
// new Intern { AlbumNumber = 102137,
// Name = "Jan", Email = "s102137@student.pg.edu.pl",
// Surname = "Kowalski", Semester = 6,
// AlbumNumber = "123456", }
// Email = "s123456@student.pg.edu.pl", };
// Semester = 4, await Context.Students.AddRangeAsync(interns);
// Course = new Course await Context.SaveChangesAsync();
// { }
// Name = "Informatyka",
// DesiredSemesters = new List<int> { 4, 6 }, public async Task FillInternshipTypes()
// ProgramEntries = new List<InternshipProgramEntry> {
// { var internshipTypes = new List<InternshipTypeReadModel>
// new InternshipProgramEntry {
// { new InternshipTypeReadModel
// Description = "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych." {
// }, Type = "FreeInternship",
// new InternshipProgramEntry Description = "Praktyka bezpłatna",
// { },
// Description = "Implementacja polityki bezpieczeństwa informacji w firmie lub instytucji, instalacja ochrony antywirusowej, konfiguracja zapór ogniowych." new InternshipTypeReadModel
// }, {
// new InternshipProgramEntry Type = "GraduateInternship"
// { },
// Description = "Instalacja, konfiguracja i administracja oprogramowania, w szczególnościsystemów operacyjnychiserwerów aplikacji." new InternshipTypeReadModel
// }, {
// new InternshipProgramEntry Type = "FreeApprenticeship"
// { },
// Description = "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań." new InternshipTypeReadModel
// } {
// } Type = "PaidApprenticeship",
// } Description = "np. przemysłowy"
// }, },
// new Intern { new InternshipTypeReadModel
// Name = "Adam", {
// Surname = "Kołek", Type = "ForeignInternship",
// AlbumNumber = "102137", Description = "np. IAESTE, ERASMUS"
// Email = "s102137@student.pg.edu.pl", },
// Semester = 6, new InternshipTypeReadModel
// Course = new Course {
// { Type = "UOP"
// Name = "Robotyka", },
// DesiredSemesters = new List<int> { 6 }, new InternshipTypeReadModel
// ProgramEntries = new List<InternshipProgramEntry> {
// { Type = "UD"
// new InternshipProgramEntry },
// { new InternshipTypeReadModel
// Description = "Testowanie oprogramowania, także z wykorzystaniem narzędzi do testowania automatycznego." {
// }, Type = "UZ"
// new InternshipProgramEntry },
// { new InternshipTypeReadModel
// Description = "Wykorzystanie otwartych komponentów programowych z uwzględnieniem prawnych zależności pomiędzy nimi a produktem wynikowym." {
// }, Type = "Other",
// new InternshipProgramEntry Description = "Należy wprowadzić samodzielnie"
// { }
// Description = "Projektowanie i implementacja baz danych oraz badanie ich wydajności." };
// }, await Context.InternshipTypes.AddRangeAsync(internshipTypes);
// new InternshipProgramEntry await Context.SaveChangesAsync();
// { }
// Description = "Projektowanie i prototypowaniezaawansowanychinterfejsów użytkownika."
// } public async Task FillSubjects()
// } {
// } var subjects = new List<InternshipSubjectReadModel>
// } {
// }; new InternshipSubjectReadModel
// Context.Interns.AddRange(interns); {
// await Context.SaveChangesAsync(); Description = "Modelowanie baz danych"
// } },
// new InternshipSubjectReadModel
// public async Task FillInternshipTypes() { {
// var internshipTypes = new List<InternshipType> Description = "Oprogramowywanie kart graficznych"
// { },
// new InternshipType new InternshipSubjectReadModel
// { {
// Type = "FreeInternship", Description = "Projektowanie UI"
// Description = "Praktyka bezpłatna", }
// }, };
// new InternshipType await Context.Subjects.AddRangeAsync(subjects);
// { await Context.SaveChangesAsync();
// Type = "GraduateInternship" }
// },
// new InternshipType public async Task FillEditions()
// { {
// Type = "FreeApprenticeship" var editions = new List<EditionReadModel>
// }, {
// new InternshipType new EditionReadModel
// { {
// Type = "PaidApprenticeship", EditionStart = new DateTime(2000, 5, 10),
// Description = "np. przemysłowy" EditionFinish = new DateTime(2000, 11, 10),
// }, ReportingStart = new DateTime(2000, 9, 30),
// new InternshipType AvailableSubjects = new List<EditionSubject>
// { {
// Type = "ForeignInternship", new EditionSubject
// Description = "np. IAESTE, ERASMUS" {
// }, InternshipId = Context.Subjects
// new InternshipType .First(i => i.Description.Equals("Modelowanie baz danych"))
// { .Id,
// Type = "UOP" },
// }, new EditionSubject
// new InternshipType {
// { InternshipId = Context.Subjects
// Type = "UD" .First(i => i.Description.Equals("Oprogramowywanie kart graficznych"))
// }, .Id
// new InternshipType },
// { new EditionSubject
// Type = "UZ" {
// }, InternshipId = Context.Subjects
// new InternshipType .First(i => i.Description.Equals("Projektowanie UI"))
// { .Id
// Type = "Other", }
// Description = "Należy wprowadzić samodzielnie" }.ToImmutableList(),
// } Course = new Course
// }; {
// Context.InternshipTypes.AddRange(internshipTypes); Name = "Informatyka",
// await Context.SaveChangesAsync(); }
// } }
// };
// public async Task FillEditions() { await Context.Editions.AddRangeAsync(editions);
// var editions = new List<Edition> await Context.SaveChangesAsync();
// { }
// new Edition
// { public async Task FillInternShips()
// StartDate = new DateTime(2000, 5, 10), {
// EndDate = new DateTime(2000, 11, 10), var intenrships = new List<InternshipReadModel>
// IPPDeadlineDate = new DateTime(2000, 9, 30), {
// Subjects = new List<InternshipProgramEntry> new InternshipReadModel
// { {
// Context.InternshipProgramEntries Student = Context.Students.First(i => i.AlbumNumber.Equals(123456)),
// .Where(i => i.Description == "Instalacja, konfiguracja i administracja niewielkich sieci komputerowych, w tym bezprzewodowych.") InternshipRegistration = new InternshipRegistrationReadModel()
// .First(), {
// Context.InternshipProgramEntries Company = Context.Companies.First(c => c.Nip.Equals("9570752316")), //Intel
// .Where(i => i.Description == "Projektowanie, implementacja i modyfikacjeoprogramowaniaw różnych technologiach i dla różnych zastosowań.") Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
// .First() Start = new DateTime(2000, 7, 1),
// } End = new DateTime(2000, 8, 30),
// } State = DocumentState.Submitted,
// }; BranchAddress =
// Context.Editions.AddRange(editions); Context.Companies
// await Context.SaveChangesAsync(); .Include(c => c.Branches)
// } .First(c => c.Nip.Equals("9570752316"))
// .Branches
// public async Task FillInternShips() { .First(),
// var edition = Context.Editions.First(); },
// InternshipProgram = new InternshipProgramReadModel()
// var intenrships = new List<Internship> {
// { FirstName = "Horacy",
// new Internship LastName = "Wościcki",
// { Email = "howos@intel.com",
// Intern = Context.Interns.Where(i => i.AlbumNumber == "123456").First(), PhoneNumber = "605-555-555",
// Edition = edition, ChosenSubjects = new List<ProgramSubject>
// BranchOffice = {
// Context.Companies new ProgramSubject
// .Where(c => c.Nip == "9570752316") //Intel {
// .First() InternshipSubjectId =
// .Branches Context.Subjects
// .First(), .First(s => s.Description.Equals("Projektowanie UI"))
// Type = Context.InternshipTypes.Where(t => t.Type == "UOP").First(), .Id
// StartDate = new DateTime(2000, 7, 1), },
// EndDate = new DateTime(2000, 8, 30), new ProgramSubject
// IsAccepted = false, {
// DeanAcceptance = new DeanAcceptance InternshipSubjectId =
// { Context.Subjects
// AcceptanceDate = new DateTime(2000, 6, 26), .First(s => s.Description.Equals("Oprogramowywanie kart graficznych"))
// IsDeansAcceptanceRequired = true, .Id
// Reason = DeanAcceptanceReason.Semester }
// }, }
// Insurance = new Insurance },
// { },
// InsuranceDeliveryDate = new DateTime(2000, 6, 29), new InternshipReadModel
// IsInsuranceRequired = true {
// }, Student = Context.Students.First(i => i.AlbumNumber == 102137),
// LengthInWeeks = 9, InternshipRegistration = new InternshipRegistrationReadModel()
// Grade = 0, {
// Program = new List<InternshipProgramEntry> Company = Context.Companies.First(c => c.Nip.Equals("5842068320")), //Asseco
// { Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
// edition.Subjects.First() Start = new DateTime(2000, 7, 1),
// }, End = new DateTime(2000, 8, 30),
// Mentor = new Mentor State = DocumentState.Submitted,
// { BranchAddress =
// Name = "Horacy", Context.Companies
// Surname = "Wościcki", .Include(c => c.Branches)
// Email = "howos@intel.com", .First(c => c.Nip.Equals("5842068320"))
// Phone = "605-555-555" .Branches
// } .First(),
// }, },
// new Internship InternshipProgram = new InternshipProgramReadModel()
// { {
// Intern = Context.Interns.Where(i => i.AlbumNumber == "102137").First(), FirstName = "Henryk",
// Edition = edition, LastName = "Polaciński",
// BranchOffice = Email = "hepol@asseco.pl",
// Context.Companies PhoneNumber = "555-525-545",
// .Where(c => c.Nip == "5842068320") //Asseco ChosenSubjects = new List<ProgramSubject>
// .First() {
// .Branches new ProgramSubject
// .First(), {
// Type = Context.InternshipTypes.Where(t => t.Type == "UZ").First(), InternshipSubjectId =
// StartDate = new DateTime(2000, 7, 1), Context.Subjects
// EndDate = new DateTime(2000, 8, 30), .First(s => s.Description.Equals("Modelowanie baz danych"))
// IsAccepted = false, .Id
// DeanAcceptance = new DeanAcceptance }
// { },
// IsDeansAcceptanceRequired = false },
// }, },
// Insurance = new Insurance };
// { await Context.Internships.AddRangeAsync(intenrships);
// InsuranceDeliveryDate = new DateTime(2000, 6, 29), await Context.SaveChangesAsync();
// IsInsuranceRequired = true }
// }, }
// LengthInWeeks = 9, }
// Grade = 0,
// Program = new List<InternshipProgramEntry>
// {
// edition.Subjects.First()
// },
// Mentor = new Mentor
// {
// Name = "Horacy",
// Surname = "Wościcki",
// Email = "howos@intel.com",
// Phone = "605-555-555"
// }
// }
// };
// Context.Internships.AddRange(intenrships);
// await Context.SaveChangesAsync();
// }
// }
// }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using InternshipSystem.Core; using InternshipSystem.Core;
namespace InternshipSystem.Repository.Model namespace InternshipSystem.Repository.Model
@ -8,6 +9,7 @@ namespace InternshipSystem.Repository.Model
public long Id { get; set; } public long Id { get; set; }
public string Nip { get; set; } public string Nip { get; set; }
public string Name { get; set; } public string Name { get; set; }
public Uri SiteAddress { get; set; }
public RangeOfActivity Range { get; set; } public RangeOfActivity Range { get; set; }
public List<BranchOfficeReadModel> Branches { get; set; } public List<BranchOfficeReadModel> Branches { get; set; }
} }