private void AddSplitHourEntries(decimal hours, TimeEntryHours hourEntry, List <TimeEntryHours> finalHours, decimal threshold, HourTypes underThresholdType, HourTypes overThresholdType) { var overtimeHours = hours - threshold; var regularHours = hourEntry.Duration - overtimeHours; hourEntry.Duration = regularHours; hourEntry.HoursType = underThresholdType; finalHours.Add(hourEntry); finalHours.Add(new TimeEntryHours() { TimeEntryId = hourEntry.TimeEntryId, Duration = overtimeHours, HoursType = overThresholdType }); }
public List<HourType> Get(HourTypes request) { var repository = GetHourTypeRepository(); var returnEntity = repository.Read(); return TranslateToHourTypesResponse(returnEntity); }
private List <TimeEntryHours> ProcessHoursForDay(List <TimeEntryHours> hourEntries, decimal threshold, HourTypes underThresholdType, HourTypes overThresholdType) { decimal hours = 0; var finalHours = new List <TimeEntryHours>(); foreach (var hourEntry in hourEntries) { if (hours > threshold) { hourEntry.HoursType = overThresholdType; finalHours.Add(hourEntry); } else { hours += hourEntry.Duration; if (hours > threshold) { AddSplitHourEntries(hours, hourEntry, finalHours, threshold, underThresholdType, overThresholdType); } else { hourEntry.HoursType = underThresholdType; finalHours.Add(hourEntry); } } } return(finalHours); }