private EmployeeProfileRfid AddEntranceStatus(string rfid) { double entryTime = Convert.ToDouble(TimeSpan.Parse(AttendanceDefinition.GetDefinition().EntryTime).TotalSeconds) + 1800; double nowTime = Convert.ToDouble(TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds); EmployeeAttendance employeeAttendance = new EmployeeAttendance() { UserId = GetUserIdByRfid(rfid), EntryTime = DateTime.Now.ToString("HH:mm:ss"), Years = DateTime.Now.Year.ToString(), Months = DateTime.Now.ToString("MMMM"), Day = DateTime.Now.ToString("dddd"), LocalDate = DateTime.Now.ToString("yyyy-MM-dd"), Status = nowTime <= entryTime ? 1 : 0, Fine = nowTime <= entryTime ? 0 : 50 }; int countRow = _attendanceGateway.AddEntranceStatus(employeeAttendance); if (countRow > 0) { EmployeeProfileRfid employeeProfileRfid = _attendanceGateway.GetEmployeeInfo(rfid); employeeProfileRfid.AttendanceStatus = nowTime <= entryTime ? "Present" : "Late"; employeeProfileRfid.TimeAndDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return(employeeProfileRfid); } return(new EmployeeProfileRfid { Status = "Something Wrong!" }); }
private bool IsNowEntryTime() { var definition = AttendanceDefinition.GetDefinition(); double nowTime = Convert.ToDouble(TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds); double entryTime = Convert.ToDouble(TimeSpan.Parse(definition.EntryTime).TotalSeconds); double leavingTime = Convert.ToDouble(TimeSpan.Parse(definition.LeavingTime).TotalSeconds); return(nowTime >= entryTime && nowTime < leavingTime); }