Continued to work on the update student handler
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user