public static Models.Domain.InternalEmployee MergeExisting(Models.Domain.InternalEmployee existingRecord, Models.Domain.InternalEmployee model) { //merge the historical lists //does the current job passed in exist, key off startdate if (model.JobDetails != null) { var currentJob = model.JobDetails.FirstOrDefault(); if (currentJob != null) { model.JobDetails.AddRange(existingRecord.JobDetails.Where(j => j.StartDate != currentJob.StartDate)); } else { model.JobDetails.AddRange(existingRecord.JobDetails); } } model.ActionLogs.AddRange(existingRecord.ActionLogs); model.ActionLogs.Add(new ActionLog() { ActionDate = DateTime.Now, ActionDescription = "Updated object" }); return(model); }
private static Models.Public.Address GetAddress(Models.Domain.AddressTypes type, Models.Domain.InternalEmployee employee) { Models.Public.Address address = null; var sourceAddress = employee.Addresses.Where(a => a.AddressType == type).FirstOrDefault(); if (sourceAddress != null) { address = new Models.Public.Address() { AddressLine1 = sourceAddress.AddressLine1, AddressLine2 = sourceAddress.AddressLine2, AddressLine3 = sourceAddress.AddressLine3, City = sourceAddress.City, CountryCode = sourceAddress.CountryCode, PostalCode = sourceAddress.PostalCode, StateProvince = sourceAddress.StateProvince }; } return(address); }
private static string GetPhone(Models.Domain.PhoneNumberTypes type, Models.Domain.InternalEmployee employee) { var phone = employee.PhoneNumbers.Where(p => p.PhoneNumberType == type).FirstOrDefault(); return(phone == null ? String.Empty : phone.Number); }