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

@@ -4,6 +4,7 @@ using BrightGlimmer.Service.Commands;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -27,12 +28,31 @@ namespace BrightGlimmer.Service.Handlers.CommandHandlers
student.MiddleName = request.MiddleName;
student.LastName = request.LastName;
student.Email = request.Email;
if (student.Address != null)
{
if (request.Address != null)
{
/* TODO: CALL TO SET LAT LONG */
student.UpdateAddress(request.Address);
}
if (student.Phones != null)
{
var newPhones = new List<Phone>();
foreach (var phone in request.Phones)
{
if (!student.UpdatePhone(phone))
{
newPhones.Add(phone);
}
}
foreach (var newPhone in newPhones)
{
student.AddPhone(newPhone);
}
}
await repository.UnitOfWork.SaveChangesAsync();
return student;
}
}