Beispiel #1
0
        public async Task <OutputBase> ClockOut(ClockoutInput input)
        {
            var user = await GetCurrentUserAsync();

            var employee = _employeeRepository.FirstOrDefault(emp => emp.Id == user.Id);
            var date     = new TimeStamp(Clock.Now, true).Date;

            var attendance = _attendanceRepository.FirstOrDefault(at => at.Date == date && at.EmployeeId == employee.Id);

            if (attendance == null)
            {
                return(new OutputBase {
                    Message = "You have not been clocked in for today", Success = false
                });
            }
            attendance.ClockOut = Clock.Now;
            _attendanceRepository.Update(attendance);

            return(new OutputBase
            {
                Message = string.Format("Good bye {0}! You have been clocked out", employee.Fullname),
                Success = true
            });
        }