Continued to work on the update student handler

This commit is contained in:
2019-04-29 13:54:10 -04:00
parent 8cacaa36ce
commit 9f2b9bcff9
10 changed files with 114 additions and 24 deletions

View File

@@ -9,12 +9,12 @@ 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 string StreetAddress1 { get; private set; }
public string StreetAddress2 { get; private set; }
public string City { get; private set; }
public string StateCode { get; private set; }
public string County { get; private set; }
public string ZipCode { get; private set; }
[JsonIgnore]
public decimal Latitude { get; private set; }
[JsonIgnore]
@@ -56,9 +56,14 @@ namespace BrightGlimmer.Domain
Longitude = longitude;
}
public void Update(Address address)
internal void Update(Address address)
{
StreetAddress1 = address.StreetAddress1;
StreetAddress2 = address.StreetAddress2;
City = address.City;
StateCode = address.StateCode;
County = address.County;
ZipCode = address.ZipCode;
}
public void SetLatitudeAndLongitude(decimal latitude, decimal longitude)

View File

@@ -29,5 +29,19 @@ namespace BrightGlimmer.Domain
IsActive = isActive;
Term = term;
}
public AssignedCourse(AssignedCourse assignedCourse)
{
Grade = assignedCourse.Grade;
IsActive = assignedCourse.IsActive;
Term = assignedCourse.Term;
}
public void Update(AssignedCourse assignedCourse)
{
Grade = assignedCourse.Grade;
IsActive = assignedCourse.IsActive;
Term = assignedCourse.Term;
}
}
}

View File

@@ -8,9 +8,9 @@ namespace BrightGlimmer.Domain
[Table("Courses")]
public class Course : Entity
{
public string Name { get; private set; }
public string Description { get; private set; }
public string Code { get; private set; }
public string Name { get; set; }
public string Description { get; set; }
public string Code { get; set; }
private Course() { }
@@ -20,5 +20,12 @@ namespace BrightGlimmer.Domain
Description = description;
Code = code;
}
public void Update(Course course)
{
Name = course.Name;
Description = course.Description;
Code = course.Code;
}
}
}

View File

@@ -6,7 +6,7 @@ using System.Text;
namespace BrightGlimmer.Domain
{
public class Entity
public abstract class Entity
{
[Key]
public Guid Id { get; private set; }

View File

@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
@@ -8,9 +9,12 @@ namespace BrightGlimmer.Domain
[Table("Phones")]
public class Phone : Entity
{
public PhoneType Type { get; set; }
public int AreaCode { get; set; }
public int Number { get; set; }
[JsonProperty]
public PhoneType Type { get; private set; }
[JsonProperty]
public int AreaCode { get; private set; }
[JsonProperty]
public int Number { get; private set; }
private Phone() { }
@@ -20,5 +24,19 @@ namespace BrightGlimmer.Domain
AreaCode = areaCode;
Number = number;
}
public Phone(Phone phone)
{
Type = phone.Type;
AreaCode = phone.AreaCode;
Number = phone.Number;
}
internal void Update(Phone phone)
{
Type = phone.Type;
AreaCode = phone.AreaCode;
Number = Number;
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
namespace BrightGlimmer.Domain
@@ -47,18 +48,33 @@ namespace BrightGlimmer.Domain
MiddleName = student.MiddleName;
LastName = student.LastName;
Email = student.Email;
}
if ()
public void UpdateAddress(Address address)
{
Address.Update(address);
}
public bool UpdatePhone(Phone phone)
{
var existingPhone = Phones.SingleOrDefault(x => x.Id == phone.Id);
if (existingPhone == null)
{
return false;
}
existingPhone.Update(phone);
return true;
}
public void AddPhone(Phone phone)
{
phones.Add(phone);
phones.Add(new Phone(phone));
}
public void AddAssignedCourse(AssignedCourse assignedCourse)
{
assignedCourses.Add(assignedCourse);
assignedCourses.Add(new AssignedCourse(assignedCourse));
}
}
}