using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using InternshipSystem.Core; using InternshipSystem.Core.Entity.Internship; using InternshipSystem.Core.UglyOrmArtifacts; using Microsoft.EntityFrameworkCore; namespace InternshipSystem.Repository { public class DatabaseFiller { private InternshipDbContext Context { get; } public DatabaseFiller(InternshipDbContext context) { Context = context; } public async Task FillAll() { await FillCompanies(); await FillInternshipTypes(); await FillEditions(); await FillStaticPages(); } public async Task FillCompanies() { var companies = new List { new Company { Name = "Intel", // SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"), Nip = "9570752316", Branches = new List { new BranchOffice { Address = new BranchAddress { City = "Gdańsk", Street = "ul. Słowackiego", Building = "173", PostalCode = "80-298", Country = "Poland", } }, new BranchOffice { Address = new BranchAddress { City = "Gdańsk", Street = "Jana z Kolna", Building = "11", PostalCode = "80-001", Country = "Poland", } }, new BranchOffice { Address = new BranchAddress { City = "Boston", Street = "State St", Building = "53", PostalCode = "MA 02109", Country = "Stany Zjednoczone", } } } }, new Company { Name = "Asseco Poland", // SiteAddress = new Uri("http://pl.asseco.com"), Nip = "5842068320", Branches = new List { new BranchOffice { Address = new BranchAddress { City = "Gdańsk", Street = "ul. Podolska", Building = "21", PostalCode = "81-321", Country = "Poland" } }, new BranchOffice { Address = new BranchAddress { City = "Wrocław", Street = "Traugutta", Building = "1/7", PostalCode = "50-449", Country = "Poland" } } } } }; await Context.Companies.AddRangeAsync(companies); await Context.SaveChangesAsync(); } public async Task FillInternshipTypes() { var internshipTypes = new List { new InternshipType { Label = "Umowa o organizację praktyki", LabelEng = "Internship agreement", Description = "Praktyka bezpłatna", DescriptionEng = "Free internship", }, new InternshipType { Label = "Umowa o praktykę absolwencką", LabelEng = "Graduate internship agreement", }, new InternshipType { Label = "Umowa o staż bezpłatny", LabelEng = "Free apprenticeship agreement", }, new InternshipType { Label = "Umowa o staż płatny", LabelEng = "Paid apprenticeship agreement", Description = "np. staż przemysłowy", DescriptionEng = "e.g. industrial apprenticeship", }, new InternshipType { Label = "Praktyka Zagraniczna", LabelEng = "Foreign Internship", Description = "IAESTE, ERASMUS", DescriptionEng = "IAESTE, ERASMUS", }, new InternshipType { Label = "Umowa o pracę", LabelEng = "Contract of employment", }, new InternshipType { Label = "Umowa o dzieło (w tym B2B)", LabelEng = "Contract work (including B2B)", }, new InternshipType { Label = "Umowa zlecenia (w tym B2B)", LabelEng = "Contract of mandate (including B2B)", }, }; await Context.InternshipTypes.AddRangeAsync(internshipTypes); await Context.SaveChangesAsync(); } public async Task FillEditions() { var editions = new List { new Edition { Id = Guid.Parse("138da8a3-855c-4b17-9bd2-5f357679efa9"), EditionStart = new DateTime(2020, 5, 10), EditionFinish = new DateTime(2020, 12, 10), ReportingStart = new DateTime(2020, 9, 30), AvailableSubjects = new List { new EditionSubject { Subject = new InternshipSubject { Description = "Modelowanie baz danych", DescriptionEng = "Database modeling", } }, new EditionSubject { Subject = new InternshipSubject { Description = "Oprogramowywanie kart graficznych", DescriptionEng = "Graphics card software", } }, new EditionSubject { Subject = new InternshipSubject { Description = "Projektowanie UI", DescriptionEng = "UI design", } } }, Course = new Course { Name = "Informatyka", }, AvailableInternshipTypes = new List { new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")) }, new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")) }, new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło (w tym B2B)")) }, new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o organizację praktyki")) } }, Internships = new List(), }, new Edition { Id = Guid.Parse("bd0da085-8e51-400d-9630-bdab3f9f6cc8"), EditionStart = new DateTime(2019, 5, 10), EditionFinish = new DateTime(2019, 12, 10), ReportingStart = new DateTime(2019, 9, 30), AvailableSubjects = new List { new EditionSubject { Subject = new InternshipSubject { Description = "Modelowanie baz danych", DescriptionEng = "Database modeling", } }, new EditionSubject { Subject = new InternshipSubject { Description = "Oprogramowywanie kart graficznych", DescriptionEng = "Graphics card software", } }, new EditionSubject { Subject = new InternshipSubject { Description = "Projektowanie UI", DescriptionEng = "UI design", } } }, Course = new Course { Name = "Inżynieria Biomedyczna", }, AvailableInternshipTypes = new List { new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")) }, new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")) }, new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło (w tym B2B)")) }, new EditionInternshipType { InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o organizację praktyki")) } }, Internships = new List(), } }; var edition = editions.First(); edition.Internships.AddRange( new List { new Internship { Student = new Student { FirstName = "Jan", LastName = "Kowalski", AlbumNumber = 123456, Email = "s123456@student.pg.edu.pl", }, InternshipRegistration = new InternshipRegistration { Company = Context.Companies.First(c => c.Name.Equals("Intel")), Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")), Start = new DateTime(2000, 7, 1), End = new DateTime(2000, 8, 30), State = DocumentState.Submitted, BranchAddress = Context.Companies .Include(c => c.Branches) .First(c => c.Name.Equals("Intel")) .Branches .First(), Mentor = new Mentor { FirstName = "Horacy", LastName = "Wościcki", Email = "howos@intel.com", PhoneNumber = "605-555-555", }, Subjects = new List { new ProgramSubject { Subject = edition.AvailableSubjects .First(s => s.Subject.Description.Equals("Modelowanie baz danych")) .Subject }, new ProgramSubject { Subject = edition.AvailableSubjects .First(s => s.Subject.Description.Equals("Projektowanie UI")) .Subject } } }, }, new Internship { Student = new Student { FirstName = "Adam", LastName = "Kołek", AlbumNumber = 102137, Email = "s102137@student.pg.edu.pl", }, InternshipRegistration = new InternshipRegistration { Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")), Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")), Start = new DateTime(2000, 7, 1), End = new DateTime(2000, 8, 30), State = DocumentState.Submitted, BranchAddress = Context.Companies .Include(c => c.Branches) .First(c => c.Name.Equals("Asseco Poland")) .Branches .First(), Mentor = new Mentor { FirstName = "Henryk", LastName = "Polaciński", Email = "hepol@asseco.pl", PhoneNumber = "555-525-545", }, Subjects = new List { new ProgramSubject { Subject = edition.AvailableSubjects .First(s => s.Subject.Description.Equals("Oprogramowywanie kart graficznych")) .Subject } }, }, }, }); await Context.Editions.AddRangeAsync(editions); await Context.SaveChangesAsync(); } public async Task FillStaticPages() { var staticPages = new List { new StaticPage { AccessName = "regulations", Title = "Regulamin Praktyk", TitleEng = "Internship Regulations", Content = "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; Duo Reges: constructio interrete. Eam tum adesse, cum dolor omnis absit; Sed ad bona praeterita redeamus. Facillimum id quidem est, inquam. Apud ceteros autem philosophos, qui quaesivit aliquid, tacet;

" + "

Quorum altera prosunt, nocent altera. Eam stabilem appellas. Sed nimis multa. Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? Quod quidem nobis non saepe contingit. Si autem id non concedatur, non continuo vita beata tollitur. " + "Illum mallem levares, quo optimum atque humanissimum virum, Cn. Id est enim, de quo quaerimus.

Ille vero, si insipiens-quo certe, quoniam tyrannus -, numquam beatus; Sin dicit obscurari quaedam nec apparere, quia valde parva sint, nos quoque concedimus; Et quod est munus, quod opus sapientiae? Ab hoc autem quaedam non melius quam veteres, quaedam omnino relicta.

" + "

Prosto z bazy danych ;D

", ContentEng = "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; Duo Reges: constructio interrete. Eam tum adesse, cum dolor omnis absit; Sed ad bona praeterita redeamus. Facillimum id quidem est, inquam. Apud ceteros autem philosophos, qui quaesivit aliquid, tacet;

" + "

Quorum altera prosunt, nocent altera. Eam stabilem appellas. Sed nimis multa. Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? Quod quidem nobis non saepe contingit. Si autem id non concedatur, non continuo vita beata tollitur. " + "Illum mallem levares, quo optimum atque humanissimum virum, Cn. Id est enim, de quo quaerimus.

Ille vero, si insipiens-quo certe, quoniam tyrannus -, numquam beatus; Sin dicit obscurari quaedam nec apparere, quia valde parva sint, nos quoque concedimus; Et quod est munus, quod opus sapientiae? Ab hoc autem quaedam non melius quam veteres, quaedam omnino relicta.

" + "

Straight from the database ;D

", }, new StaticPage { AccessName = "info", Title = "Informacje", TitleEng = "Information", Content = "

Nowe zmiany:

", ContentEng = "

New changes:

", } }; await Context.StaticPages.AddRangeAsync(staticPages); await Context.SaveChangesAsync(); } } }