public void CountWorkTimeThisMonth()
        {
            List <ClockInOut> dataIn = new List <ClockInOut>
            {
                new ClockInOut
                {
                    UserId = 1,
                    Date   = new DateTime(2020, DateTime.UtcNow.Month, 19, 9, 10, 0),
                    Type   = ClockType.In
                },
            };
            List <ClockInOut> dataOut = new List <ClockInOut>
            {
                new ClockInOut
                {
                    UserId = 1,
                    Date   = new DateTime(2020, DateTime.UtcNow.Month, 19, 11, 20, 0),
                    Type   = ClockType.Out
                }
            };

            BalanceDto result = CountBalance.CountWorkTimeCurrent(dataIn, dataOut);

            result.HoursWorked.Should().Be(2);
            result.MinutesWorked.Should().Be(10);
        }
        public void CountWorkTime_UserWorks2HoursAnd10MinutesInTheSameDay_ReturnCorrectAmountOfHoursAndMinutes()
        {
            List <ClockInOut> dataIn = new List <ClockInOut>
            {
                new ClockInOut
                {
                    UserId = 1,
                    Date   = new DateTime(2020, 08, 19, 9, 10, 0),
                    Type   = ClockType.In
                },
            };
            List <ClockInOut> dataOut = new List <ClockInOut>
            {
                new ClockInOut
                {
                    UserId = 1,
                    Date   = new DateTime(2020, 08, 19, 11, 20, 0),
                    Type   = ClockType.Out
                }
            };

            BalanceDto result = CountBalance.CountWorkTime(dataIn, dataOut);

            result.HoursWorked.Should().Be(2);
            result.MinutesWorked.Should().Be(10);
            result.HoursLeft.Should().Be(157);
            result.MinutesLeft.Should().Be(50);
        }
        public BalanceDto BalanceToThisDay(int id)
        {
            var clockInOutRepository = new ClockInOutRepository(_repository);
            var datesIn  = clockInOutRepository.GetClockInsForThisMonth(id).ToList();
            var datesOut = clockInOutRepository.GetClockOutsForThisMonth(id).ToList();

            if (datesIn.Count > datesOut.Count)
            {
                datesIn.RemoveAt(datesIn.Count - 1);
            }

            return(CountBalance.CountWorkTimeCurrent(datesIn, datesOut));
        }
        public BalanceDto Balance(int id)
        {
            var clockInOutRepository = new ClockInOutRepository(_repository);
            var datesIn  = clockInOutRepository.GetClockInsForThisMonth(id).ToList();
            var datesOut = clockInOutRepository.GetClockOutsForThisMonth(id).ToList();


            var lastRecord = _repository.ReadLast(id);

            if (lastRecord?.Type == ClockType.In)
            {
                datesIn.RemoveAt(datesIn.Count - 1);
            }


            return(CountBalance.CountWorkTime(datesIn, datesOut));
        }
        public void CloseCurrentDayToCalculateBalance()
        {
            List <ClockInOut> dataIn = new List <ClockInOut>
            {
                new ClockInOut
                {
                    UserId = 1,
                    Date   = new DateTime(2020, DateTime.UtcNow.Month, 19, 9, 10, 0),
                    Type   = ClockType.In
                },
            };
            List <ClockInOut> dataOut = new List <ClockInOut>();


            BalanceDto result = CountBalance.CountWorkTimeCurrent(dataIn, dataOut);

            dataIn.Count.Should().Equals(dataOut.Count);
        }