Flesh out domain and start student commands
This commit is contained in:
@@ -14,12 +14,23 @@ namespace BrightGlimmer.Data
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// dotnet ef migrations add NAME --project ./BrightGlimmer.Data --startup-project ./BrightGlimmer.Api
|
||||
// dotnet ef migrations update --project ./BrightGlimmer.Data --startup-project ./BrightGlimmer.Api
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasMany(x => x.Phones);
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasOne(x => x.Address);
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasMany(x => x.AssignedCourses);
|
||||
modelBuilder.Entity<AssignedCourse>()
|
||||
.HasOne(x => x.Course);
|
||||
}
|
||||
|
||||
public DbSet<Student> Students { get; set; }
|
||||
public DbSet<Course> Courses { get; set; }
|
||||
public DbSet<AssignedCourse> AssignedCourses { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BrightGlimmer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(BgContext))]
|
||||
[Migration("20190420001348_CreateDatabase")]
|
||||
partial class CreateDatabase
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Data.Domain.Phone", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AreaCode");
|
||||
|
||||
b.Property<int>("Number");
|
||||
|
||||
b.Property<Guid?>("StudentId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("Phone");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Data.Domain.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Email");
|
||||
|
||||
b.Property<string>("FirstName");
|
||||
|
||||
b.Property<string>("LastName");
|
||||
|
||||
b.Property<string>("MiddleName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Data.Domain.Phone", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Data.Domain.Student")
|
||||
.WithMany("Phones")
|
||||
.HasForeignKey("StudentId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
public partial class CreateDatabase : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Students",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
FirstName = table.Column<string>(nullable: true),
|
||||
MiddleName = table.Column<string>(nullable: true),
|
||||
LastName = table.Column<string>(nullable: true),
|
||||
Email = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Students", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Phone",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
AreaCode = table.Column<int>(nullable: false),
|
||||
Number = table.Column<int>(nullable: false),
|
||||
StudentId = table.Column<Guid>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Phone", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Phone_Students_StudentId",
|
||||
column: x => x.StudentId,
|
||||
principalTable: "Students",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Phone_StudentId",
|
||||
table: "Phone",
|
||||
column: "StudentId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Phone");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Students");
|
||||
}
|
||||
}
|
||||
}
|
||||
190
BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.Designer.cs
generated
Normal file
190
BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.Designer.cs
generated
Normal file
@@ -0,0 +1,190 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BrightGlimmer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(BgContext))]
|
||||
[Migration("20190424174147_CreateDatabase")]
|
||||
partial class CreateDatabase
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Address", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("City");
|
||||
|
||||
b.Property<string>("County");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<decimal>("Latitude");
|
||||
|
||||
b.Property<decimal>("Longitude");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("StateCode");
|
||||
|
||||
b.Property<string>("StreetAddress1");
|
||||
|
||||
b.Property<string>("StreetAddress2");
|
||||
|
||||
b.Property<string>("ZipCode");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Addresses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<Guid?>("CourseId");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<decimal>("Grade");
|
||||
|
||||
b.Property<bool>("IsActive");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<Guid?>("StudentId");
|
||||
|
||||
b.Property<string>("Term");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CourseId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("AssignedCourses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Course", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Code");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Courses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Phone", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AreaCode");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<int>("Number");
|
||||
|
||||
b.Property<Guid?>("StudentId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("Phones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<Guid?>("AddressId");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<string>("Email");
|
||||
|
||||
b.Property<string>("FirstName");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<string>("LastName");
|
||||
|
||||
b.Property<string>("MiddleName");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("ProfilePictureUrl");
|
||||
|
||||
b.Property<int>("StudentNumber");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Domain.Course", "Course")
|
||||
.WithMany()
|
||||
.HasForeignKey("CourseId");
|
||||
|
||||
b.HasOne("BrightGlimmer.Domain.Student", "Student")
|
||||
.WithMany("AssignedCourses")
|
||||
.HasForeignKey("StudentId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Phone", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Domain.Student")
|
||||
.WithMany("Phones")
|
||||
.HasForeignKey("StudentId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Student", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Domain.Address", "Address")
|
||||
.WithMany()
|
||||
.HasForeignKey("AddressId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
170
BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs
Normal file
170
BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs
Normal file
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
public partial class CreateDatabase : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Addresses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
IsDeleted = table.Column<bool>(nullable: false),
|
||||
CreatedDate = table.Column<DateTime>(nullable: false),
|
||||
ModifiedDate = table.Column<DateTime>(nullable: false),
|
||||
StreetAddress1 = table.Column<string>(nullable: true),
|
||||
StreetAddress2 = table.Column<string>(nullable: true),
|
||||
City = table.Column<string>(nullable: true),
|
||||
StateCode = table.Column<string>(nullable: true),
|
||||
County = table.Column<string>(nullable: true),
|
||||
ZipCode = table.Column<string>(nullable: true),
|
||||
Latitude = table.Column<decimal>(nullable: false),
|
||||
Longitude = table.Column<decimal>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Addresses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Courses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
IsDeleted = table.Column<bool>(nullable: false),
|
||||
CreatedDate = table.Column<DateTime>(nullable: false),
|
||||
ModifiedDate = table.Column<DateTime>(nullable: false),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Description = table.Column<string>(nullable: true),
|
||||
Code = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Courses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Students",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
IsDeleted = table.Column<bool>(nullable: false),
|
||||
CreatedDate = table.Column<DateTime>(nullable: false),
|
||||
ModifiedDate = table.Column<DateTime>(nullable: false),
|
||||
StudentNumber = table.Column<int>(nullable: false),
|
||||
FirstName = table.Column<string>(nullable: true),
|
||||
MiddleName = table.Column<string>(nullable: true),
|
||||
LastName = table.Column<string>(nullable: true),
|
||||
Email = table.Column<string>(nullable: true),
|
||||
AddressId = table.Column<Guid>(nullable: true),
|
||||
ProfilePictureUrl = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Students", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Students_Addresses_AddressId",
|
||||
column: x => x.AddressId,
|
||||
principalTable: "Addresses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AssignedCourses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
IsDeleted = table.Column<bool>(nullable: false),
|
||||
CreatedDate = table.Column<DateTime>(nullable: false),
|
||||
ModifiedDate = table.Column<DateTime>(nullable: false),
|
||||
Grade = table.Column<decimal>(nullable: false),
|
||||
IsActive = table.Column<bool>(nullable: false),
|
||||
Term = table.Column<string>(nullable: true),
|
||||
StudentId = table.Column<Guid>(nullable: true),
|
||||
CourseId = table.Column<Guid>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AssignedCourses", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_AssignedCourses_Courses_CourseId",
|
||||
column: x => x.CourseId,
|
||||
principalTable: "Courses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_AssignedCourses_Students_StudentId",
|
||||
column: x => x.StudentId,
|
||||
principalTable: "Students",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Phones",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(nullable: false),
|
||||
IsDeleted = table.Column<bool>(nullable: false),
|
||||
CreatedDate = table.Column<DateTime>(nullable: false),
|
||||
ModifiedDate = table.Column<DateTime>(nullable: false),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
AreaCode = table.Column<int>(nullable: false),
|
||||
Number = table.Column<int>(nullable: false),
|
||||
StudentId = table.Column<Guid>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Phones", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Phones_Students_StudentId",
|
||||
column: x => x.StudentId,
|
||||
principalTable: "Students",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AssignedCourses_CourseId",
|
||||
table: "AssignedCourses",
|
||||
column: "CourseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AssignedCourses_StudentId",
|
||||
table: "AssignedCourses",
|
||||
column: "StudentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Phones_StudentId",
|
||||
table: "Phones",
|
||||
column: "StudentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Students_AddressId",
|
||||
table: "Students",
|
||||
column: "AddressId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AssignedCourses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Phones");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Courses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Students");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Addresses");
|
||||
}
|
||||
}
|
||||
}
|
||||
188
BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs
Normal file
188
BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BrightGlimmer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(BgContext))]
|
||||
partial class BgContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Address", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("City");
|
||||
|
||||
b.Property<string>("County");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<decimal>("Latitude");
|
||||
|
||||
b.Property<decimal>("Longitude");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("StateCode");
|
||||
|
||||
b.Property<string>("StreetAddress1");
|
||||
|
||||
b.Property<string>("StreetAddress2");
|
||||
|
||||
b.Property<string>("ZipCode");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Addresses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<Guid?>("CourseId");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<decimal>("Grade");
|
||||
|
||||
b.Property<bool>("IsActive");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<Guid?>("StudentId");
|
||||
|
||||
b.Property<string>("Term");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CourseId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("AssignedCourses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Course", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Code");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Courses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Phone", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AreaCode");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<int>("Number");
|
||||
|
||||
b.Property<Guid?>("StudentId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("Phones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<Guid?>("AddressId");
|
||||
|
||||
b.Property<DateTime>("CreatedDate");
|
||||
|
||||
b.Property<string>("Email");
|
||||
|
||||
b.Property<string>("FirstName");
|
||||
|
||||
b.Property<bool>("IsDeleted");
|
||||
|
||||
b.Property<string>("LastName");
|
||||
|
||||
b.Property<string>("MiddleName");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("ProfilePictureUrl");
|
||||
|
||||
b.Property<int>("StudentNumber");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Domain.Course", "Course")
|
||||
.WithMany()
|
||||
.HasForeignKey("CourseId");
|
||||
|
||||
b.HasOne("BrightGlimmer.Domain.Student", "Student")
|
||||
.WithMany("AssignedCourses")
|
||||
.HasForeignKey("StudentId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Phone", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Domain.Student")
|
||||
.WithMany("Phones")
|
||||
.HasForeignKey("StudentId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Domain.Student", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Domain.Address", "Address")
|
||||
.WithMany()
|
||||
.HasForeignKey("AddressId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BrightGlimmer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(BgContext))]
|
||||
partial class SqliteDatabaseContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Data.Domain.Phone", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AreaCode");
|
||||
|
||||
b.Property<int>("Number");
|
||||
|
||||
b.Property<Guid?>("StudentId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("Phone");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Data.Domain.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Email");
|
||||
|
||||
b.Property<string>("FirstName");
|
||||
|
||||
b.Property<string>("LastName");
|
||||
|
||||
b.Property<string>("MiddleName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BrightGlimmer.Data.Domain.Phone", b =>
|
||||
{
|
||||
b.HasOne("BrightGlimmer.Data.Domain.Student")
|
||||
.WithMany("Phones")
|
||||
.HasForeignKey("StudentId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
20
BrightGlimmer.Domain/Address.cs
Normal file
20
BrightGlimmer.Domain/Address.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BrightGlimmer.Domain
|
||||
{
|
||||
[Table("Addresses")]
|
||||
public class Address : Entity
|
||||
{
|
||||
public string StreetAddress1 { get; set; }
|
||||
public string StreetAddress2 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string StateCode { get; set; }
|
||||
public string County { get; set; }
|
||||
public string ZipCode { get; set; }
|
||||
public decimal Latitude { get; set; }
|
||||
public decimal Longitude { get; set; }
|
||||
}
|
||||
}
|
||||
18
BrightGlimmer.Domain/AssignedCourse.cs
Normal file
18
BrightGlimmer.Domain/AssignedCourse.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BrightGlimmer.Domain
|
||||
{
|
||||
[Table("AssignedCourses")]
|
||||
public class AssignedCourse : Entity
|
||||
{
|
||||
public decimal Grade { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public string Term { get; set; }
|
||||
|
||||
public Student Student { get; set; }
|
||||
public Course Course { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,10 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.ComponentModel.Annotations">
|
||||
<HintPath>..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2\System.ComponentModel.Annotations.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BrightGlimmer.Domain
|
||||
{
|
||||
[Table("Courses")]
|
||||
public class Course : Entity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -7,5 +7,16 @@ namespace BrightGlimmer.Domain
|
||||
public class Entity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public DateTime ModifiedDate { get; set; }
|
||||
|
||||
public Entity()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
CreatedDate = DateTime.UtcNow;
|
||||
ModifiedDate = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BrightGlimmer.Domain
|
||||
{
|
||||
[Table("Phones")]
|
||||
public class Phone : Entity
|
||||
{
|
||||
public PhoneType Type { get; set; }
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace BrightGlimmer.Domain
|
||||
{
|
||||
[Table("Students")]
|
||||
public class Student : Entity
|
||||
{
|
||||
[NotMapped]
|
||||
private readonly int MAX_STUDENT_NUMBER = 100000000;
|
||||
|
||||
public int StudentNumber { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string MiddleName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public List<Phone> Phones { get; set; }
|
||||
public Address Address { get; set; }
|
||||
public string ProfilePictureUrl { get; set; }
|
||||
public List<AssignedCourse> AssignedCourses { get; set; }
|
||||
|
||||
public Student() : base()
|
||||
{
|
||||
StudentNumber = new Random().Next(MAX_STUDENT_NUMBER); /* TODO: Optimize student number creation */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Interfaces\" />
|
||||
<Folder Include="Handlers\CommandHandlers\" />
|
||||
<Folder Include="Commands\" />
|
||||
<Folder Include="Handlers\QueryHandlers\" />
|
||||
<Folder Include="Queries\" />
|
||||
</ItemGroup>
|
||||
|
||||
11
BrightGlimmer.Service/Commands/CreateStudentCommand.cs
Normal file
11
BrightGlimmer.Service/Commands/CreateStudentCommand.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using MediatR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BrightGlimmer.Service.Commands
|
||||
{
|
||||
public class CreateStudentCommand : IRequest<bool>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,11 @@ namespace BrightGlimmer.Services.Handlers.QueryHandlers
|
||||
|
||||
public async Task<IEnumerable<Student>> Handle(GetAllStudentsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await repository.Get().ToListAsync();
|
||||
return await repository.Get()
|
||||
.Include(x => x.Phones)
|
||||
.Include(x => x.Address)
|
||||
.Include(x => x.AssignedCourses)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user