From a30e9a5b1c07dd019b6d21ea5080b5f0de08396d Mon Sep 17 00:00:00 2001 From: Giovani Date: Wed, 24 Apr 2019 17:50:37 +0000 Subject: [PATCH] Flesh out domain and start student commands --- BrightGlimmer.Data/BgContext.cs | 11 + .../20190420001348_CreateDatabase.Designer.cs | 68 ------- .../20190420001348_CreateDatabase.cs | 61 ------ .../20190424174147_CreateDatabase.Designer.cs | 190 ++++++++++++++++++ .../20190424174147_CreateDatabase.cs | 170 ++++++++++++++++ .../Migrations/BgContextModelSnapshot.cs | 188 +++++++++++++++++ .../SqliteDatabaseContextModelSnapshot.cs | 66 ------ BrightGlimmer.Data/bright_glimmer.db | Bin 32768 -> 69632 bytes BrightGlimmer.Domain/Address.cs | 20 ++ BrightGlimmer.Domain/AssignedCourse.cs | 18 ++ .../BrightGlimmer.Domain.csproj | 6 + BrightGlimmer.Domain/Course.cs | 2 + BrightGlimmer.Domain/Entity.cs | 11 + BrightGlimmer.Domain/Phone.cs | 2 + BrightGlimmer.Domain/Student.cs | 14 ++ .../BrightGlimmer.Service.csproj | 1 - .../Commands/CreateStudentCommand.cs | 11 + .../GetAllStudentsQueryHandler.cs | 6 +- 18 files changed, 648 insertions(+), 197 deletions(-) delete mode 100644 BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.Designer.cs delete mode 100644 BrightGlimmer.Data/Migrations/20190420001348_CreateDatabase.cs create mode 100644 BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.Designer.cs create mode 100644 BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs create mode 100644 BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs delete mode 100644 BrightGlimmer.Data/Migrations/SqliteDatabaseContextModelSnapshot.cs create mode 100644 BrightGlimmer.Domain/Address.cs create mode 100644 BrightGlimmer.Domain/AssignedCourse.cs create mode 100644 BrightGlimmer.Service/Commands/CreateStudentCommand.cs 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 4616386cd8daaef586cc16d276355e0a16086b37..50d21859df77d6b9c3e05692816924b916447e60 100644 GIT binary patch literal 69632 zcmeI&&2QUe0LSsT>5{&s?M|kes+k}VRrgYNg^B}$EOkpDO}jKh9TJMt+ABtFGHiEZ z;?!+S@KA* zj;Gzp&F2&)_pzqsa=9__dsY0(*Od4$F29I(W$1I-$Fbb48@r{szjE_qZf^GXxnE}f znEh$`yP2OS-3^ReX(wLJZ^d8QZzE{0W|o)E3bRGkSXR!KWFr;VwU4@%S?!%V?r>|d z6>}ra#tIDj>9-$S9q&lKR8*^?BX6g5#P3kejBRK3mHm(vQ@arsSbA2UE~*O)$_v-) z92{Fdng4etXs1=VTQ{_Fs9BoQ#H%bYwY&A5yINzXr8Vx?>socEvDa!=YK@jC{aIU9 z*lpIfE6oSmXU2mYvaY*f9b29yHX%wITShb7iY!uftd1zKA^w!Lma#9|2-=Y)wtJ@i z(7v!p>&YWgJFSU|XrkIPFDTJCJvp$P^eqf>6;KFQZF8q-)V3OZ zpJ-IIrm<->jYiejiykul9QTi-4Wn*|h;dQ2P4wf{gEksKQUQUmzR|vx6a2t7PHvbsc0HvYelx@(7q}bBQ-BEA6rhRKm3XD zs=1Xz&whMCI$D-W>+qLjnEFNTw+>-PQ2=*v}rr8*XW#t!5+%ywr!fnR?5nHC$*k&(y@;dvOc(Y zj|95B>+~Ml;*w$?dZ&(c-$|$+3%yj9w-(}JJk&rm@Pif6yamfG_u|0ao+zl*#k9bM z9ns~d$*1pJDXQ15DbL?Jk63VE1#g9Dzy?R%KRqdiH7+q;DXG}7+(XBH=rPys( zz1KZTS}%rPA1|oJ^|YZ6N1?5UAFrJ4E8_WLU3t25KK$*rvAJy@Iid@_uKS7YdOhb! z;=-|LEE3BMA`))1f8mN;?&Ei@DH}@2jX1xVr-$C>mg5c`8-bS4sErlWFW1vF65DC( ziHq~%L35)2uvrqn%G|Fx@xu!N1Q0*~0R#|0009ILKmY**{_O(qDfzAS)fN4Nm9^D1 zeSJ+|TW|X_USh(lbI@_E)my8#)^56%^VmMLyGJ+mm6i8b`;+?0+{>K!;e`MK2q1s} z0tg_000IagfB*vjO#v;xHF@Db3iRjy#ee$eg#ZEwAbNSu1Q0*~0R#|0009ILKmY**vM<2=fA+_i zJwyNj1Q0*~0R#|0009ILK!EvwGJpUA2q1s}0tg_000IagfI#*InE%iI7_)~6AbX5?2q1s} q0tg_000IagfB*srWM6>i|Ll)3dx!u62q1s}0tg_000IagfWY6?tR}z! delta 584 zcmZozz|zpbG(lRBm4ShQ1BhXOZK95`G%JIiP5>|e4+eJb^9+2K_}B98;akX~&pVO( z{ANLcQ11FTc6MIYQ!6Ym9RG^F|&)y$}%>K zgUyE8S`4FECR=dEO;+VfVddr0)MuIO!>zaZA|Hz&yMcj$p|Od@<~#Cy0x-_xkNU!F zjQqP8_;&#VW&?kK3nQD3G=scngWRp0j(GweYu`-TJ!|2`eeRk0Wr=y2LHQ{~ndzme zRp}6ZPHARw5lqY>JvT8kM=v=)mkSshjQnpH_}^?6GC(NwFiEbhnetstandard2.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(); } } }