418 lines
20 KiB
C#
418 lines
20 KiB
C#
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<Company>
|
|
{
|
|
new Company
|
|
{
|
|
Name = "Intel",
|
|
// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
|
|
Nip = "9570752316",
|
|
Branches = new List<BranchOffice>
|
|
{
|
|
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<BranchOffice>
|
|
{
|
|
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<InternshipType>
|
|
{
|
|
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<Edition>
|
|
{
|
|
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<EditionSubject>
|
|
{
|
|
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<EditionInternshipType>
|
|
{
|
|
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<Internship>(),
|
|
},
|
|
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<EditionSubject>
|
|
{
|
|
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<EditionInternshipType>
|
|
{
|
|
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<Internship>(),
|
|
}
|
|
};
|
|
|
|
var edition = editions.First();
|
|
edition.Internships.AddRange(
|
|
new List<Internship>
|
|
{
|
|
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<ProgramSubject>
|
|
{
|
|
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<ProgramSubject>
|
|
{
|
|
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<StaticPage>
|
|
{
|
|
new StaticPage
|
|
{
|
|
AccessName = "regulations",
|
|
Title = "Regulamin Praktyk",
|
|
TitleEng = "Internship Regulations",
|
|
Content =
|
|
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; <b>Duo Reges: constructio interrete.</b> <i>Eam tum adesse, cum dolor omnis absit;</i> Sed ad bona praeterita redeamus. <mark>Facillimum id quidem est, inquam.</mark> Apud ceteros autem philosophos, qui quaesivit aliquid, tacet; </p>" +
|
|
"<p><a href=\"http://loripsum.net/\" target=\"_blank\">Quorum altera prosunt, nocent altera.</a> Eam stabilem appellas. <i>Sed nimis multa.</i> Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? <mark>Quod quidem nobis non saepe contingit.</mark> Si autem id non concedatur, non continuo vita beata tollitur. " +
|
|
"<a href=\"http://loripsum.net/\" target=\"_blank\">Illum mallem levares, quo optimum atque humanissimum virum, Cn.</a> <i>Id est enim, de quo quaerimus.</i> </p><p>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. </p>" +
|
|
"<p>Prosto z bazy danych ;D</p>",
|
|
ContentEng =
|
|
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; <b>Duo Reges: constructio interrete.</b> <i>Eam tum adesse, cum dolor omnis absit;</i> Sed ad bona praeterita redeamus. <mark>Facillimum id quidem est, inquam.</mark> Apud ceteros autem philosophos, qui quaesivit aliquid, tacet; </p>" +
|
|
"<p><a href=\"http://loripsum.net/\" target=\"_blank\">Quorum altera prosunt, nocent altera.</a> Eam stabilem appellas. <i>Sed nimis multa.</i> Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? <mark>Quod quidem nobis non saepe contingit.</mark> Si autem id non concedatur, non continuo vita beata tollitur. " +
|
|
"<a href=\"http://loripsum.net/\" target=\"_blank\">Illum mallem levares, quo optimum atque humanissimum virum, Cn.</a> <i>Id est enim, de quo quaerimus.</i> </p><p>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. </p>" +
|
|
"<p>Straight from the database ;D</p>",
|
|
},
|
|
new StaticPage
|
|
{
|
|
AccessName = "info",
|
|
Title = "Informacje",
|
|
TitleEng = "Information",
|
|
Content =
|
|
"<p>Nowe zmiany: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
|
ContentEng =
|
|
"<p>New changes: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
|
}
|
|
};
|
|
await Context.StaticPages.AddRangeAsync(staticPages);
|
|
await Context.SaveChangesAsync();
|
|
}
|
|
}
|
|
} |