From 6da26283f94aca900dce2b4bdc2de2a23c788c10 Mon Sep 17 00:00:00 2001 From: Giovani Date: Fri, 26 Apr 2019 22:02:58 -0400 Subject: [PATCH] Added constructors to the entities --- BrightGlimmer.Domain/Address.cs | 21 +++++++++++++++++++-- BrightGlimmer.Domain/AssignedCourse.cs | 9 +++++++++ BrightGlimmer.Domain/Course.cs | 15 ++++++++++++--- BrightGlimmer.Domain/Phone.cs | 15 ++++++++++++--- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/BrightGlimmer.Domain/Address.cs b/BrightGlimmer.Domain/Address.cs index 003607e..fe741df 100644 --- a/BrightGlimmer.Domain/Address.cs +++ b/BrightGlimmer.Domain/Address.cs @@ -16,8 +16,25 @@ namespace BrightGlimmer.Domain public string County { get; set; } public string ZipCode { get; set; } [JsonIgnore] - public decimal Latitude { get; set; } + public decimal Latitude { get; private set; } [JsonIgnore] - public decimal Longitude { get; set; } + public decimal Longitude { get; private set; } + + private Address() { } + + public Address(string streetAddress1, + string streetAddress2, + string city, + string stateCode, + string county, + string zipCode) + { + StreetAddress1 = streetAddress1; + StreetAddress2 = streetAddress2; + City = city; + StateCode = stateCode; + County = county; + ZipCode = zipCode; + } } } diff --git a/BrightGlimmer.Domain/AssignedCourse.cs b/BrightGlimmer.Domain/AssignedCourse.cs index 9abf96f..b11a135 100644 --- a/BrightGlimmer.Domain/AssignedCourse.cs +++ b/BrightGlimmer.Domain/AssignedCourse.cs @@ -14,5 +14,14 @@ namespace BrightGlimmer.Domain public Student Student { get; set; } public Course Course { get; set; } + + private AssignedCourse() { } + + public AssignedCourse(decimal grade, bool isActive, string term) + { + Grade = grade; + IsActive = isActive; + Term = term; + } } } diff --git a/BrightGlimmer.Domain/Course.cs b/BrightGlimmer.Domain/Course.cs index 5540b1a..7c27bf9 100644 --- a/BrightGlimmer.Domain/Course.cs +++ b/BrightGlimmer.Domain/Course.cs @@ -8,8 +8,17 @@ namespace BrightGlimmer.Domain [Table("Courses")] public class Course : Entity { - public string Name { get; set; } - public string Description { get; set; } - public string Code { get; set; } + public string Name { get; private set; } + public string Description { get; private set; } + public string Code { get; private set; } + + private Course() { } + + public Course(string name, string description, string code) + { + Name = name; + Description = description; + Code = code; + } } } diff --git a/BrightGlimmer.Domain/Phone.cs b/BrightGlimmer.Domain/Phone.cs index 5868520..1cda3ed 100644 --- a/BrightGlimmer.Domain/Phone.cs +++ b/BrightGlimmer.Domain/Phone.cs @@ -8,8 +8,17 @@ namespace BrightGlimmer.Domain [Table("Phones")] public class Phone : Entity { - public PhoneType Type { get; set; } - public int AreaCode { get; set; } - public int Number { get; set; } + public PhoneType Type { get; private set; } + public int AreaCode { get; private set; } + public int Number { get; private set; } + + private Phone() { } + + public Phone(PhoneType type, int areaCode, int number) + { + Type = type; + AreaCode = areaCode; + Number = number; + } } }