public static void SetDefaultClockoutTimeStampToForgottenStamps(string userName)
{
var startDate = WebHelpers.GetCurrentDateTimeByTimeZoneId(WebConfigurationManager.AppSettings["UserTimeZoneId"]).Date;
using (var dbContext = new TimeTrackingEntities())
{
var userForgottenTimeOutStamps = (from utsh in dbContext.UserTimeTrackHistories
where utsh.IsDeleted == false &&
utsh.UserName.ToLower().Equals(userName.ToLower()) &&
utsh.StampDate < startDate &&
(utsh.ClockInTime.Length > 0 && (utsh.ClockOutTime == null || utsh.ClockOutTime.Length == 0))
select utsh).ToList();
if (userForgottenTimeOutStamps.Any())
{
var sDate = new DateTime();
foreach (var userForgottenTimeOutStamp in userForgottenTimeOutStamps)
{
var timeSpan = TimeSpan.Parse(WebConfigurationManager.AppSettings["AutomaticTimeOutLimit"]);
userForgottenTimeOutStamp.ClockOutTime = String.Format("{0:t}", sDate.Add(timeSpan));
userForgottenTimeOutStamp.UpdatedBy = "sys";
userForgottenTimeOutStamp.UpdatedDate = WebHelpers.GetCurrentDateTimeByTimeZoneId(WebConfigurationManager.AppSettings["UserTimeZoneId"]);
}
}
dbContext.SaveChanges();
}
}