private async Task<decimal> GetCurrentSalary()
        {
            var sessionId = _sessionManager.GetSessionId(Request, Response);
            var salaryInfo = await _salaryRepository.GetLatestSalaryDetail(sessionId);

            if (salaryInfo != null)
            {
                return salaryInfo.SalaryValue;
            }
            else
            {
                return 0;
            }
        }
Ejemplo n.º 2
0
        // TODO Deal with client timezone, as this will only work if the server timezone is the same
        public async Task <decimal> GetAmountEarnedToday(Guid sessionId)
        {
            var salaryInfo = await _salaryRepository.GetLatestSalaryDetail(sessionId);

            if (!salaryInfo.WorkingHoursId.HasValue)
            {
                return(0);
            }

            var workingHours = await _salaryRepository.GetWorkingHours(salaryInfo.WorkingHoursId.Value);

            var totalHours = await Task.Run(() => this.GetWorkingHoursThisYear(workingHours));

            if (totalHours <= 0.0)
            {
                return(0);
            }

            if (salaryInfo.SalaryType != SalaryType.Annual)
            {
                throw new NotImplementedException();
            }

            var amountEarnedPerHour = salaryInfo.SalaryValue / (decimal)totalHours;

            // So now we know how much they earn per hour, but must work out how long they've been working today

            var hoursWorkedToday = workingHours.HoursWorkedToday();

            return(amountEarnedPerHour * (decimal)hoursWorkedToday);
        }