diff --git a/BrightGlimmer.Data/BgContext.cs b/BrightGlimmer.Data/BgContext.cs index d560f73..04f494e 100644 --- a/BrightGlimmer.Data/BgContext.cs +++ b/BrightGlimmer.Data/BgContext.cs @@ -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() .HasMany(x => x.Phones); + modelBuilder.Entity() + .HasOne(x => x.Address); + modelBuilder.Entity() + .HasMany(x => x.AssignedCourses); + modelBuilder.Entity() + .HasOne(x => x.Course); } public DbSet Students { get; set; } + public DbSet Courses { get; set; } + public DbSet AssignedCourses { get; set; } } } diff --git a/BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.Designer.cs b/BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.Designer.cs deleted file mode 100644 index d4256a1..0000000 --- a/BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.Designer.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -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("Id") - .ValueGeneratedOnAdd(); - - b.Property("AreaCode"); - - b.Property("Number"); - - b.Property("StudentId"); - - b.Property("Type"); - - b.HasKey("Id"); - - b.HasIndex("StudentId"); - - b.ToTable("Phone"); - }); - - modelBuilder.Entity("BrightGlimmer.Data.Domain.Student", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Email"); - - b.Property("FirstName"); - - b.Property("LastName"); - - b.Property("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 - } - } -} diff --git a/BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.cs b/BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.cs deleted file mode 100644 index 0a215d0..0000000 --- a/BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.cs +++ /dev/null @@ -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(nullable: false), - FirstName = table.Column(nullable: true), - MiddleName = table.Column(nullable: true), - LastName = table.Column(nullable: true), - Email = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Students", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Phone", - columns: table => new - { - Id = table.Column(nullable: false), - Type = table.Column(nullable: false), - AreaCode = table.Column(nullable: false), - Number = table.Column(nullable: false), - StudentId = table.Column(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"); - } - } -} diff --git a/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.Designer.cs b/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.Designer.cs new file mode 100644 index 0000000..3a364a0 --- /dev/null +++ b/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.Designer.cs @@ -0,0 +1,190 @@ +// +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("Id") + .ValueGeneratedOnAdd(); + + b.Property("City"); + + b.Property("County"); + + b.Property("CreatedDate"); + + b.Property("IsDeleted"); + + b.Property("Latitude"); + + b.Property("Longitude"); + + b.Property("ModifiedDate"); + + b.Property("StateCode"); + + b.Property("StreetAddress1"); + + b.Property("StreetAddress2"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CourseId"); + + b.Property("CreatedDate"); + + b.Property("Grade"); + + b.Property("IsActive"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("StudentId"); + + b.Property("Term"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("AssignedCourses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Code"); + + b.Property("CreatedDate"); + + b.Property("Description"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Courses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Phone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AreaCode"); + + b.Property("CreatedDate"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("Number"); + + b.Property("StudentId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.ToTable("Phones"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddressId"); + + b.Property("CreatedDate"); + + b.Property("Email"); + + b.Property("FirstName"); + + b.Property("IsDeleted"); + + b.Property("LastName"); + + b.Property("MiddleName"); + + b.Property("ModifiedDate"); + + b.Property("ProfilePictureUrl"); + + b.Property("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 + } + } +} diff --git a/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs b/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs new file mode 100644 index 0000000..e93a11e --- /dev/null +++ b/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs @@ -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(nullable: false), + IsDeleted = table.Column(nullable: false), + CreatedDate = table.Column(nullable: false), + ModifiedDate = table.Column(nullable: false), + StreetAddress1 = table.Column(nullable: true), + StreetAddress2 = table.Column(nullable: true), + City = table.Column(nullable: true), + StateCode = table.Column(nullable: true), + County = table.Column(nullable: true), + ZipCode = table.Column(nullable: true), + Latitude = table.Column(nullable: false), + Longitude = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Addresses", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Courses", + columns: table => new + { + Id = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + CreatedDate = table.Column(nullable: false), + ModifiedDate = table.Column(nullable: false), + Name = table.Column(nullable: true), + Description = table.Column(nullable: true), + Code = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Courses", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Students", + columns: table => new + { + Id = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + CreatedDate = table.Column(nullable: false), + ModifiedDate = table.Column(nullable: false), + StudentNumber = table.Column(nullable: false), + FirstName = table.Column(nullable: true), + MiddleName = table.Column(nullable: true), + LastName = table.Column(nullable: true), + Email = table.Column(nullable: true), + AddressId = table.Column(nullable: true), + ProfilePictureUrl = table.Column(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(nullable: false), + IsDeleted = table.Column(nullable: false), + CreatedDate = table.Column(nullable: false), + ModifiedDate = table.Column(nullable: false), + Grade = table.Column(nullable: false), + IsActive = table.Column(nullable: false), + Term = table.Column(nullable: true), + StudentId = table.Column(nullable: true), + CourseId = table.Column(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(nullable: false), + IsDeleted = table.Column(nullable: false), + CreatedDate = table.Column(nullable: false), + ModifiedDate = table.Column(nullable: false), + Type = table.Column(nullable: false), + AreaCode = table.Column(nullable: false), + Number = table.Column(nullable: false), + StudentId = table.Column(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"); + } + } +} diff --git a/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs b/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs new file mode 100644 index 0000000..c039b2b --- /dev/null +++ b/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs @@ -0,0 +1,188 @@ +// +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("Id") + .ValueGeneratedOnAdd(); + + b.Property("City"); + + b.Property("County"); + + b.Property("CreatedDate"); + + b.Property("IsDeleted"); + + b.Property("Latitude"); + + b.Property("Longitude"); + + b.Property("ModifiedDate"); + + b.Property("StateCode"); + + b.Property("StreetAddress1"); + + b.Property("StreetAddress2"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CourseId"); + + b.Property("CreatedDate"); + + b.Property("Grade"); + + b.Property("IsActive"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("StudentId"); + + b.Property("Term"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("AssignedCourses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Code"); + + b.Property("CreatedDate"); + + b.Property("Description"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Courses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Phone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AreaCode"); + + b.Property("CreatedDate"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("Number"); + + b.Property("StudentId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.ToTable("Phones"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddressId"); + + b.Property("CreatedDate"); + + b.Property("Email"); + + b.Property("FirstName"); + + b.Property("IsDeleted"); + + b.Property("LastName"); + + b.Property("MiddleName"); + + b.Property("ModifiedDate"); + + b.Property("ProfilePictureUrl"); + + b.Property("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 + } + } +} diff --git a/BrightGlimmer.Data/Migrations/SqliteDatabaseContextModelSnapshot.cs b/BrightGlimmer.Data/Migrations/SqliteDatabaseContextModelSnapshot.cs deleted file mode 100644 index d44294a..0000000 --- a/BrightGlimmer.Data/Migrations/SqliteDatabaseContextModelSnapshot.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -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("Id") - .ValueGeneratedOnAdd(); - - b.Property("AreaCode"); - - b.Property("Number"); - - b.Property("StudentId"); - - b.Property("Type"); - - b.HasKey("Id"); - - b.HasIndex("StudentId"); - - b.ToTable("Phone"); - }); - - modelBuilder.Entity("BrightGlimmer.Data.Domain.Student", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Email"); - - b.Property("FirstName"); - - b.Property("LastName"); - - b.Property("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 - } - } -} diff --git a/BrightGlimmer.Data/bright_glimmer.db b/BrightGlimmer.Data/bright_glimmer.db index 4616386..50d2185 100644 Binary files a/BrightGlimmer.Data/bright_glimmer.db and b/BrightGlimmer.Data/bright_glimmer.db differ diff --git a/BrightGlimmer.Domain/Address.cs b/BrightGlimmer.Domain/Address.cs new file mode 100644 index 0000000..0a86620 --- /dev/null +++ b/BrightGlimmer.Domain/Address.cs @@ -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; } + } +} diff --git a/BrightGlimmer.Domain/AssignedCourse.cs b/BrightGlimmer.Domain/AssignedCourse.cs new file mode 100644 index 0000000..9abf96f --- /dev/null +++ b/BrightGlimmer.Domain/AssignedCourse.cs @@ -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; } + } +} diff --git a/BrightGlimmer.Domain/BrightGlimmer.Domain.csproj b/BrightGlimmer.Domain/BrightGlimmer.Domain.csproj index 9f5c4f4..e8027fa 100644 --- a/BrightGlimmer.Domain/BrightGlimmer.Domain.csproj +++ b/BrightGlimmer.Domain/BrightGlimmer.Domain.csproj @@ -4,4 +4,10 @@ netstandard2.0 + + + ..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2\System.ComponentModel.Annotations.dll + + + diff --git a/BrightGlimmer.Domain/Course.cs b/BrightGlimmer.Domain/Course.cs index f111c71..5540b1a 100644 --- a/BrightGlimmer.Domain/Course.cs +++ b/BrightGlimmer.Domain/Course.cs @@ -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; } diff --git a/BrightGlimmer.Domain/Entity.cs b/BrightGlimmer.Domain/Entity.cs index 86d619f..dce4fd1 100644 --- a/BrightGlimmer.Domain/Entity.cs +++ b/BrightGlimmer.Domain/Entity.cs @@ -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; + } } + } diff --git a/BrightGlimmer.Domain/Phone.cs b/BrightGlimmer.Domain/Phone.cs index 99bb05e..5868520 100644 --- a/BrightGlimmer.Domain/Phone.cs +++ b/BrightGlimmer.Domain/Phone.cs @@ -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; } diff --git a/BrightGlimmer.Domain/Student.cs b/BrightGlimmer.Domain/Student.cs index 3188119..8c8acd1 100644 --- a/BrightGlimmer.Domain/Student.cs +++ b/BrightGlimmer.Domain/Student.cs @@ -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 Phones { get; set; } + public Address Address { get; set; } + public string ProfilePictureUrl { get; set; } + public List AssignedCourses { get; set; } + + public Student() : base() + { + StudentNumber = new Random().Next(MAX_STUDENT_NUMBER); /* TODO: Optimize student number creation */ + } } } diff --git a/BrightGlimmer.Service/BrightGlimmer.Service.csproj b/BrightGlimmer.Service/BrightGlimmer.Service.csproj index ef92186..a764589 100644 --- a/BrightGlimmer.Service/BrightGlimmer.Service.csproj +++ b/BrightGlimmer.Service/BrightGlimmer.Service.csproj @@ -7,7 +7,6 @@ - diff --git a/BrightGlimmer.Service/Commands/CreateStudentCommand.cs b/BrightGlimmer.Service/Commands/CreateStudentCommand.cs new file mode 100644 index 0000000..8787ce5 --- /dev/null +++ b/BrightGlimmer.Service/Commands/CreateStudentCommand.cs @@ -0,0 +1,11 @@ +using MediatR; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BrightGlimmer.Service.Commands +{ + public class CreateStudentCommand : IRequest + { + } +} diff --git a/BrightGlimmer.Service/Handlers/QueryHandlers/GetAllStudentsQueryHandler.cs b/BrightGlimmer.Service/Handlers/QueryHandlers/GetAllStudentsQueryHandler.cs index f551612..a829f88 100644 --- a/BrightGlimmer.Service/Handlers/QueryHandlers/GetAllStudentsQueryHandler.cs +++ b/BrightGlimmer.Service/Handlers/QueryHandlers/GetAllStudentsQueryHandler.cs @@ -20,7 +20,11 @@ namespace BrightGlimmer.Services.Handlers.QueryHandlers public async Task> 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(); } } }