Fleshed out entity classes and created command to create student
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
@@ -14,7 +15,9 @@ namespace BrightGlimmer.Domain
|
||||
public string StateCode { get; set; }
|
||||
public string County { get; set; }
|
||||
public string ZipCode { get; set; }
|
||||
[JsonIgnore]
|
||||
public decimal Latitude { get; set; }
|
||||
[JsonIgnore]
|
||||
public decimal Longitude { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\newtonsoft.json\11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<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>
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
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; }
|
||||
[Key]
|
||||
public Guid Id { get; private set; }
|
||||
[JsonIgnore]
|
||||
public bool IsDeleted { get; protected set; }
|
||||
[JsonIgnore]
|
||||
public DateTime CreatedDate { get; protected set; }
|
||||
[JsonIgnore]
|
||||
public DateTime ModifiedDate { get; protected set; }
|
||||
|
||||
public Entity()
|
||||
{
|
||||
@@ -17,6 +23,15 @@ namespace BrightGlimmer.Domain
|
||||
CreatedDate = DateTime.UtcNow;
|
||||
ModifiedDate = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Delete()
|
||||
{
|
||||
IsDeleted = true;
|
||||
}
|
||||
|
||||
protected void MarkModified()
|
||||
{
|
||||
ModifiedDate = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,19 +11,44 @@ namespace BrightGlimmer.Domain
|
||||
[NotMapped]
|
||||
private readonly int MAX_STUDENT_NUMBER = 100000000;
|
||||
|
||||
public int StudentNumber { get; set; }
|
||||
public int StudentNumber { get; private 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 string Email { get; private set; }
|
||||
public Address Address { get; set; }
|
||||
public string ProfilePictureUrl { get; set; }
|
||||
public List<AssignedCourse> AssignedCourses { get; set; }
|
||||
|
||||
public Student() : base()
|
||||
private readonly List<Phone> phones = new List<Phone>();
|
||||
public IReadOnlyList<Phone> Phones => phones;
|
||||
|
||||
private readonly List<AssignedCourse> assignedCourses = new List<AssignedCourse>();
|
||||
public IReadOnlyList<AssignedCourse> AssignedCourses => assignedCourses;
|
||||
|
||||
private Student() { }
|
||||
|
||||
public Student(string firstName,
|
||||
string lastName,
|
||||
string email,
|
||||
List<Phone> phones,
|
||||
Address address) : base()
|
||||
{
|
||||
StudentNumber = new Random().Next(MAX_STUDENT_NUMBER); /* TODO: Optimize student number creation */
|
||||
FirstName = firstName;
|
||||
LastName = lastName;
|
||||
Email = email;
|
||||
Address = address;
|
||||
this.phones = phones;
|
||||
}
|
||||
|
||||
public void AddPhone(Phone phone)
|
||||
{
|
||||
phones.Add(phone);
|
||||
}
|
||||
|
||||
public void AddAssignedCourse(AssignedCourse assignedCourse)
|
||||
{
|
||||
assignedCourses.Add(assignedCourse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user