public async Task <int> AdditionalDaysGetNumberOfDays(Guid employeeUID) { var daysoff = await AdditionalDaysRepository.AdditonalDaysGetAllAdditionalDays(employeeUID); int numberOfDaysToReturn = daysoff.Select(x => x.AdditionalDaysNumberOfAdditionalDays).Count(); return(numberOfDaysToReturn); }
public async Task <int> RequestGetTotalAvailableDays(Guid employeeUID) { var additionalDays = await AdditionalDaysRepository.AdditionalDayGetTotalAdditionalDays(employeeUID); var employeeBacklogDays = await EmployeeRepository.EmployeeGetEmployeeBacklogDays(employeeUID); var totalDaysToReturn = additionalDays + employeeBacklogDays; return(totalDaysToReturn); }
public async Task <AdditionalDaysEntity> AdditionalDaysGetAdditionalDay(Guid additionalDayUID) { var daysoff = await AdditionalDaysRepository.AdditionalDaysGetAdditionalDay(additionalDayUID); return(new AdditionalDaysEntity() { AdditionalDaysUID = daysoff.AdditionaDaysUID, AdditionalDaysNumberOfAdditionalDays = daysoff.AdditionalDaysNumberOfAdditionalDays, AdditionalDaysReason = daysoff.AdditionalDaysReason }); }
public async Task <List <AdditionalDaysEntity> > AdditionalDaysGetAllAdditionalDays(Guid employeeUID) { var daysoff = await AdditionalDaysRepository.AdditonalDaysGetAllAdditionalDays(employeeUID); var daysoffToReturn = daysoff.Where(x => x.AdditionalDaysDeletedOn == null) .Select(x => new AdditionalDaysEntity() { AdditionalDaysUID = x.AdditionaDaysUID, AdditionalDaysNumberOfAdditionalDays = x.AdditionalDaysNumberOfAdditionalDays, AdditionalDaysCreatedOn = x.AdditionalDaysCreatedOn }).ToList(); return(daysoffToReturn); }
public async Task AdditionalDaysInsert(Guid employeeUID, AdditionalDaysEntity additionalDays) { var employee = await EmployeeRepository.EmployeeGetEmployee(employeeUID); var days = new AdditionalDay() { AdditionaDaysUID = Guid.NewGuid(), AdditionalDaysNumberOfAdditionalDays = additionalDays.AdditionalDaysNumberOfAdditionalDays, AdditionalDaysReason = additionalDays.AdditionalDaysReason, AdditionalDaysCreatedOn = DateTime.UtcNow, EmployeeID = employee.EmployeeID }; await AdditionalDaysRepository.AdditionalDaysInsert(days); }
public async Task <bool> AdditionalDaysValidateHasDaysOff(Guid employeeUID, DateTime startDate, DateTime endDate) { var numberOfBusinessDays = 1 + ((endDate - startDate).TotalDays * 5 - (startDate.DayOfWeek - endDate.DayOfWeek) * 2) / 7; if (endDate.DayOfWeek == DayOfWeek.Saturday) { numberOfBusinessDays--; } if (startDate.DayOfWeek == DayOfWeek.Sunday) { numberOfBusinessDays--; } return(await AdditionalDaysRepository.AdditionalDaysHasDaysOff(employeeUID, (int)numberOfBusinessDays)); }
public async Task EmployeeDeleteEmployee(Guid employeeUID) { await EmployeeRepository.EmlpoyeeDelete(employeeUID); var requests = await RequestRepository.RequestGetAllEmployeeRequests(employeeUID); requests.Select(async x => await RequestRepository.RequestDelete(x.RequestUID)); var contracts = await ContractRepository.ContractsGetContractByEmployee(employeeUID); contracts.Select(async x => await ContractRepository.ContractDelete(x.ContractUID)); var additionalDays = await AdditionalDaysRepository.AdditonalDaysGetAllAdditionalDays(employeeUID); additionalDays.Select(async x => await AdditionalDaysRepository.AdditonalDaysDelete(x.AdditionaDaysUID)); }
public async Task AdditionalDaysRemove(Guid employeeUID, int numberOfDays) { var daysOff = await AdditionalDaysRepository.AdditonalDaysGetAllAdditionalDays(employeeUID); foreach (var day in daysOff) { numberOfDays -= day.AdditionalDaysNumberOfAdditionalDays; if (numberOfDays < 0) { day.AdditionalDaysNumberOfAdditionalDays += numberOfDays; break; } if (numberOfDays >= 0) { day.AdditionalDaysDeletedOn = DateTime.UtcNow; } } await AdditionalDaysRepository.AdditionalDaysSave(); }