public static int CalculateSecondsRemaining(Interview interview) { int totalSeconds = interview.MinutesAllowed * 60; int secondsRemaining = totalSeconds; if (interview.StartedDate.HasValue) { double elapsedSeconds = (DateTime.UtcNow - interview.StartedDate.Value).TotalSeconds; secondsRemaining = (int)(totalSeconds - elapsedSeconds); } return secondsRemaining; }
public static InterviewStatus GetInterviewStatus(Interview interview) { if (!interview.SentDate.HasValue) { return InterviewStatus.Created; } else if (!interview.StartedDate.HasValue) { return InterviewStatus.WaitingForApplicant; } else if (interview.StartedDate.Value.AddMinutes(interview.MinutesAllowed) >= DateTime.UtcNow) { return InterviewStatus.InProgress; } else { return InterviewStatus.Completed; } }