This commit is contained in:
mborzyszkowski 2020-07-29 19:38:39 +02:00
parent af2f225f6c
commit a07d5f11dd
4 changed files with 454 additions and 392 deletions

View File

@ -1,60 +1,60 @@
// using System.Threading.Tasks; using System.Threading.Tasks;
// using InternshipSystem.Repository; using InternshipSystem.Repository;
// using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
//
// namespace Internship.Api.Controller namespace 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.FillInternshipTypes();
// await FillerService.FillEditions(); await FillerService.FillEditions();
// await FillerService.FillInternShips(); await FillerService.FillInternShips();
// return Ok(); return Ok();
// } }
//
// [HttpPost("fill/companies")] [HttpPost("fill/companies")]
// public async Task<IActionResult> FillCompaniesAsync() public async Task<IActionResult> FillCompaniesAsync()
// { {
// await FillerService.FillCompany(); await FillerService.FillCompany();
// return Ok(); return Ok();
// } }
//
// [HttpPost("fill/interns")] [HttpPost("fill/students")]
// public async Task<IActionResult> FillInternsAsync() { public async Task<IActionResult> FillStudentsAsync() {
// await FillerService.FillInterns(); await FillerService.FillStudents();
// return Ok(); return Ok();
// } }
//
// [HttpPost("fill/internshiptypes")] [HttpPost("fill/internshiptypes")]
// public async Task<IActionResult> FillInternshipTypesAsync() { public async Task<IActionResult> FillInternshipTypesAsync() {
// await FillerService.FillInternshipTypes(); await FillerService.FillInternshipTypes();
// return Ok(); return Ok();
// } }
//
// [HttpPost("fill/editions")] [HttpPost("fill/editions")]
// public async Task<IActionResult> FillEditionsAsync() { public async Task<IActionResult> FillEditionsAsync() {
// await FillerService.FillEditions(); await FillerService.FillEditions();
// return Ok(); return Ok();
// } }
//
// [HttpPost("fill/internships")] [HttpPost("fill/internships")]
// public async Task<IActionResult> FillInternShipsAsync() { public async Task<IActionResult> FillInternShipsAsync() {
// await FillerService.FillInternShips(); await FillerService.FillInternShips();
// return Ok(); return Ok();
// } }
// } }
// } }

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

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