Пример #1
0
        public string CheckInOrOutByPin(int pin)
        {
            string          message  = "";
            Employee        employee = employeeRepo.GetEmployeeByPin(pin);
            ShiftRepository sr       = new ShiftRepository();
            int             shiftID  = -1;

            if (employee != null)
            {
                if (employee.OpenShift == -1)
                {
                    shiftID = sr.AddShift(employee.EmployeeId);
                    message = employee.FullName + " blev tjekket ind.";
                }
                else
                {
                    sr.EndShift(employee.OpenShift);
                    message = employee.FullName + " er tjekket ud.";
                }
                employee.OpenShift = shiftID;
            }
            else
            {
                message = "PIN-koden er forkert";
            }
            return(message);
        }
Пример #2
0
 public static ShiftRepository GetInstance()
 {
     if (instance == null)
     {
         instance = new ShiftRepository();
     }
     return(instance);
 }
Пример #3
0
        public int CalculateWorkHours(int employeeId, DateTime endDate)
        {
            int             totalAmountOfMinutes = 0;
            ShiftRepository sr = ShiftRepository.GetInstance();
            List <Shift>    shiftsSelectedMonth = sr.GetShifts(employeeId, endDate);

            foreach (Shift shift in shiftsSelectedMonth)
            {
                totalAmountOfMinutes += shift.TotalNumberOfMinutes;
            }
            return(totalAmountOfMinutes);
        }
Пример #4
0
        public string CheckShiftByPin(int pin, DateTime start, DateTime end)
        {
            string          message  = "";
            Employee        employee = employeeRepo.GetEmployeeByPin(pin);
            ShiftRepository sr       = new ShiftRepository();
            int             shiftID  = -1;

            if (employee != null)
            {
                shiftID = sr.AddShift(employee.EmployeeId, start);
                message = employee.FullName + " blev tjekket ind.";

                sr.EndShift(employee.OpenShift, end);
                message = employee.FullName + " er tjekket ud.";

                employee.OpenShift = shiftID;
            }

            return(message);
        }