private void SetInsertValues(SQLiteCommand insert) { var text = insert.CommandText; text = text.Replace("@startIn", HasStartIn() ? StartIn.ToString("yyyy-MM-ddTHH:mm:ss") : "NULL"); text = text.Replace("@lunchOut", HasLunchOut() ? LunchOut.ToString("yyyy-MM-ddTHH:mm:ss") : "NULL"); text = text.Replace("@lunchIn", HasLunchIn() ? LunchIn.ToString("yyyy-MM-ddTHH:mm:ss") : "NULL"); text = text.Replace("@endOut", HasEndOut() ? EndOut.ToString("yyyy-MM-ddTHH:mm:ss") : "NULL"); text = text.Replace("@isPaidTimeOff", IsPaidTimeOff ? "1" : "0"); text = text.Replace("@isHoliday", IsHoliday ? "1" : "0"); text = text.Replace("'NULL'", "NULL"); // drop single quotes around NULL values insert.CommandText = text; }
public DateTime GetPunchOut() { DateTime adjustedPunchIn = PunchIn.AddMinutes(GetMinuteAdjustment(PunchIn.Minute)); DateTime adjustedLunchOut = LunchOut.AddMinutes(GetMinuteAdjustment(LunchOut.Minute)); TimeSpan currentTotal = GetCurrentTotal(adjustedLunchOut, adjustedPunchIn); double lunchDuration = (LunchIn - LunchOut).TotalMinutes; double adjustedLunchDuration = lunchDuration + GetMinuteAdjustment((int)lunchDuration); TimeSpan missingTotal = GetMissingTotal(currentTotal); DateTime adjustedLunchIn = GetAdjustedLunchIn(adjustedLunchOut, adjustedLunchDuration); DateTime punchOut = GetPunchOut(adjustedLunchIn, missingTotal); return(punchOut); }