-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial data for seeding database
- Loading branch information
Showing
4 changed files
with
680 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
namespace HRPotter.Data | ||
{ | ||
|
||
|
||
public class HRPotterContext : DbContext | ||
{ | ||
public HRPotterContext(DbContextOptions<HRPotterContext> options) : base(options) { } | ||
|
@@ -15,5 +17,146 @@ public HRPotterContext(DbContextOptions<HRPotterContext> options) : base(options | |
public DbSet<JobOffer> JobOffers { get; set; } | ||
|
||
public DbSet<Company> Companies { get; set; } | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
base.OnModelCreating(modelBuilder); | ||
|
||
modelBuilder.Entity<JobApplication>().HasData( | ||
new JobApplication | ||
{ | ||
Id = 1, | ||
JobOfferId = 2, | ||
FirstName = "Stefan", | ||
LastName = "Johnson", | ||
Email = "[email protected]", | ||
Status = ApplicationStatus.ToBeReviewed, | ||
Description = String.Join(' ', Enumerable.Repeat("lorem ipsum", 5)), | ||
}, | ||
new JobApplication | ||
{ | ||
Id = 2, | ||
JobOfferId = 3, | ||
FirstName = "Bogdan", | ||
LastName = "Smith", | ||
Email = "[email protected]", | ||
Status = ApplicationStatus.ToBeReviewed | ||
}, | ||
new JobApplication | ||
{ | ||
Id = 3, | ||
JobOfferId = 5, | ||
FirstName = "Ambroży", | ||
LastName = "Miller", | ||
Email = "[email protected]", | ||
IsStudent = true, | ||
Status = ApplicationStatus.ToBeReviewed, | ||
CvUrl = new Uri("https://www.google.com") | ||
}, | ||
new JobApplication | ||
{ | ||
Id = 4, | ||
JobOfferId = 6, | ||
FirstName = "Bogusław", | ||
LastName = "Jones", | ||
Email = "[email protected]", | ||
Phone = "555444333", | ||
Status = ApplicationStatus.ToBeReviewed | ||
}, | ||
new JobApplication | ||
{ | ||
Id = 5, | ||
JobOfferId = 1, | ||
FirstName = "Lech", | ||
LastName = "Wilson", | ||
Email = "[email protected]", | ||
Status = ApplicationStatus.ToBeReviewed | ||
}, | ||
new JobApplication | ||
{ | ||
Id = 6, | ||
JobOfferId = 2, | ||
FirstName = "Orfeusz", | ||
LastName = "Williams", | ||
Email = "[email protected]", | ||
Phone = "222333111", | ||
Status = ApplicationStatus.ToBeReviewed | ||
} | ||
); | ||
|
||
modelBuilder.Entity<JobOffer>().HasData( | ||
new JobOffer | ||
{ | ||
Id = 1, | ||
JobTitle = "Backend Developer", | ||
CompanyId = 1, | ||
Created = DateTime.Now, | ||
Location = "Warsaw", | ||
SalaryTo = 15000, | ||
Description = String.Join(' ', Enumerable.Repeat("lorem ipsum", 10)) | ||
}, | ||
new JobOffer | ||
{ | ||
Id = 2, | ||
JobTitle = "Frontend Developer", | ||
CompanyId = 2, | ||
Created = DateTime.Now, | ||
ValidUntil = DateTime.Now.AddDays(10), | ||
Location = "Warsaw", | ||
SalaryFrom = 10000, | ||
Description = String.Join(' ', Enumerable.Repeat("lorem ipsum", 10)) | ||
}, | ||
new JobOffer | ||
{ | ||
Id = 3, | ||
JobTitle = "Manager", | ||
CompanyId = 1, | ||
Created = DateTime.Now, | ||
ValidUntil = DateTime.Now.AddDays(5), | ||
Location = "New York", | ||
SalaryFrom = 15000, | ||
SalaryTo = 25000 | ||
}, | ||
new JobOffer | ||
{ | ||
Id = 4, | ||
JobTitle = "Teacher", | ||
CompanyId = 3, | ||
Created = DateTime.Now, | ||
Location = "Paris", | ||
SalaryFrom = 10000, | ||
SalaryTo = 15000, | ||
Description = String.Join(' ', Enumerable.Repeat("lorem ipsum", 10)) | ||
}, | ||
new JobOffer | ||
{ | ||
Id = 5, | ||
JobTitle = "Cook", | ||
CompanyId = 4, | ||
Created = DateTime.Now, | ||
Location = "Venice", | ||
SalaryFrom = 10000, | ||
SalaryTo = 15000, | ||
Description = String.Join(' ', Enumerable.Repeat("lorem ipsum", 10)) | ||
}, | ||
new JobOffer | ||
{ | ||
Id = 6, | ||
JobTitle = "Manager", | ||
CompanyId = 1, | ||
Created = DateTime.Now, | ||
Location = "Venice", | ||
SalaryFrom = 15000, | ||
SalaryTo = 25000 | ||
} | ||
); | ||
|
||
modelBuilder.Entity<Company>().HasData( | ||
new Company { Id = 1, Name = "Microsoft" }, | ||
new Company { Id = 2, Name = "Apple" }, | ||
new Company { Id = 3, Name = "Google" }, | ||
new Company { Id = 4, Name = "EBR-IT" } | ||
); | ||
} | ||
} | ||
} |
143 changes: 143 additions & 0 deletions
143
HRPotter/Migrations/20191102183848_InitialMigration.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace HRPotter.Migrations | ||
{ | ||
public partial class InitialMigration : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Companies", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
Name = table.Column<string>(nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Companies", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "JobOffers", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
JobTitle = table.Column<string>(nullable: false), | ||
CompanyId = table.Column<int>(nullable: false), | ||
Location = table.Column<string>(nullable: false), | ||
SalaryFrom = table.Column<int>(nullable: true), | ||
SalaryTo = table.Column<int>(nullable: true), | ||
Created = table.Column<DateTime>(nullable: false), | ||
ValidUntil = table.Column<DateTime>(nullable: true), | ||
Description = table.Column<string>(nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_JobOffers", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_JobOffers_Companies_CompanyId", | ||
column: x => x.CompanyId, | ||
principalTable: "Companies", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "JobApplications", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
JobOfferId = table.Column<int>(nullable: false), | ||
FirstName = table.Column<string>(nullable: false), | ||
LastName = table.Column<string>(nullable: false), | ||
Email = table.Column<string>(nullable: false), | ||
Phone = table.Column<string>(nullable: true), | ||
CvUrl = table.Column<string>(nullable: true), | ||
IsStudent = table.Column<bool>(nullable: false), | ||
Description = table.Column<string>(nullable: true), | ||
Status = table.Column<int>(nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_JobApplications", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_JobApplications_JobOffers_JobOfferId", | ||
column: x => x.JobOfferId, | ||
principalTable: "JobOffers", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_JobApplications_JobOfferId", | ||
table: "JobApplications", | ||
column: "JobOfferId"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_JobOffers_CompanyId", | ||
table: "JobOffers", | ||
column: "CompanyId"); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "JobApplications"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "JobOffers"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Companies"); | ||
} | ||
} | ||
} |
Oops, something went wrong.