public static PartialCompletionDate Map(this IHavePartialCompletionDateEntity entity) { if (entity == null) { return(null); } // 1st possibility, no end date but is current. if (entity.endDate == null && entity.endDateParts == null && entity.isCurrent) { return(new PartialCompletionDate()); } // 2nd possibility, end date. if (entity.endDate != null && entity.endDateParts != null) { return(new PartialCompletionDate(GetPartialDate(entity.endDate.Value, entity.endDateParts.Value))); } // No other combination supported. return(null); }
public static void MapTo(this PartialCompletionDate partialCompletionDate, IHavePartialCompletionDateEntity entity) { if (partialCompletionDate == null) { entity.endDate = null; entity.endDateParts = null; entity.isCurrent = false; return; } DateTime? endDate; DateParts?endDateParts; partialCompletionDate.End.MapTo(out endDate, out endDateParts); // 1st possibility, no end date so is current. if (endDate == null) { entity.endDate = null; entity.endDateParts = null; entity.isCurrent = true; return; } // 2nd possibility, end date. entity.endDate = endDate; entity.endDateParts = (byte?)endDateParts; entity.isCurrent = false; }