public bool AddLeaveToLeaveData(LeaveApplication lvappl, LeaveType lvType, LeavePolicy lvPolicy) { //Add leave to Leave data for the implemetation in the reports DateTime datetime = new DateTime(); datetime = lvappl.FromDate; //Gets the Specific employee and his shift Expression <Func <Employee, bool> > SpecificEntries = aa => aa.PEmployeeID == lvappl.EmpID; Employee emp = EmployeeRepo.FindBy(SpecificEntries).First(); Shift shift = emp.Shift; //Gets the roster or crew information of the Employee Expression <Func <VAT_RosterDetail, bool> > SpecificEntries2 = aa => aa.CriteriaData == emp.CrewID && aa.RosterDate >= lvappl.FromDate && aa.RosterDate <= lvappl.ToDate; List <VAT_RosterDetail> rosterDetails = RosterDetailRepo.FindBy(SpecificEntries2); for (int i = 0; i < lvappl.CalenderDays; i++) { //If the user is BCL Employee his rest day count would be not be true if (lvPolicy.CountRestDays != true) { //If roster is applied to the employee if (rosterDetails.Where(aa => aa.RosterDate == datetime).Count() > 0) { VAT_RosterDetail rd = rosterDetails.First(aa => aa.RosterDate == datetime); //IF work minutes of the roster are greater than 0 it means that roster is applied system call the Leave data function and apply leave for that day. if (rd.WorkMin > 0) { AddLeaveData(lvappl, lvType, datetime); } } else { //IF current day is not if (!CurrentDayNotRest(shift, datetime)) { AddLeaveData(lvappl, lvType, datetime); } } } else { AddLeaveData(lvappl, lvType, datetime); } datetime = datetime.AddDays(1); } return(true); }
public DateTime?GetReturnDate(LeaveApplication lvapplication, LeaveType lvType, LeavePolicy lvPolicy) { DateTime returnDate = lvapplication.ToDate.AddDays(1); DateTime EndDate = lvapplication.ToDate.AddDays(7); if (lvapplication.IsHalf == true) { return(returnDate); } else { Expression <Func <Employee, bool> > SpecificEntries = aa => aa.PEmployeeID == lvapplication.EmpID; Employee emp = EmployeeRepo.FindBy(SpecificEntries).First(); Shift ss = emp.Shift; Expression <Func <VAT_RosterDetail, bool> > SpecificEntries2 = aa => aa.CriteriaData == emp.CrewID && aa.RosterDate >= lvapplication.FromDate && aa.RosterDate <= EndDate; List <VAT_RosterDetail> rosterDetails = RosterDetailRepo.FindBy(SpecificEntries2); if (lvPolicy.CountRestDays != true) { DateTime dts = returnDate; while (true) { if (rosterDetails.Where(aa => aa.RosterDate == dts).Count() > 0) { VAT_RosterDetail rd = rosterDetails.First(aa => aa.RosterDate == dts); if (rd.WorkMin > 0) { return(dts); } } else { if (CurrentDayNotRest(ss, dts) == false) { return(dts); } } dts = dts.AddDays(1); } } return(returnDate); } }
public float CalculateNoOfDays(LeaveApplication lvapplication, LeaveType lvType, LeavePolicy lvPolicy) { List <Holiday> holidays = new List <Holiday>(); holidays = DDService.GetHolidays(); float val = 0; if (lvapplication.IsHalf == true) { val = (float)0.5; } else { val = (lvapplication.ToDate - lvapplication.FromDate).Days + 1; Expression <Func <Employee, bool> > SpecificEntries = aa => aa.PEmployeeID == lvapplication.EmpID; Employee emp = EmployeeRepo.FindBy(SpecificEntries).FirstOrDefault(); Shift shift = emp.Shift; Expression <Func <VAT_RosterDetail, bool> > SpecificEntries2 = aa => aa.CriteriaData == emp.CrewID && aa.RosterDate >= lvapplication.FromDate && aa.RosterDate <= lvapplication.ToDate; List <VAT_RosterDetail> rosterDetails = RosterDetailRepo.FindBy(SpecificEntries2); if ((lvPolicy.CountRestDays != true || lvPolicy.CountGZDays != true) && lvPolicy.PLeavePolicyID != 0) { DateTime dts = lvapplication.FromDate; while (dts <= lvapplication.ToDate) { if (rosterDetails.Where(aa => aa.RosterDate == dts).Count() > 0) { VAT_RosterDetail rd = rosterDetails.First(aa => aa.RosterDate == dts); if (holidays.Where(aa => aa.HolidayDate == dts).Count() > 0 && shift.GZDays == true) { if (lvPolicy.CountGZDays == false) { val = val - 1; } } else { if (rd.WorkMin == 0) { val = val - 1; } } } else { if (holidays.Where(aa => aa.HolidayDate == dts).Count() > 0 && shift.GZDays == true) { if (lvPolicy.CountGZDays == false) { val = val - 1; } } else { if (CurrentDayNotRest(shift, dts)) { val = val - 1; } } } dts = dts.AddDays(1); } } } return(val); }