/// <summary> /// Gets the employee ListView. /// </summary> /// <param name="onboardingCollections">The onboarding collections.</param> /// <param name="staffNumber">The staff number.</param> /// <param name="staffName">Name of the staff.</param> /// <param name="message">The message.</param> /// <returns></returns> public IEmployeeOnBoardListView GetEmployeeListView( IList <IEmployee> employeeCollections, IList <ICompanyDetail> companyCollection, string sortOrder, string searchString, string message, int?page) { if (string.IsNullOrEmpty(searchString)) { searchString = ""; } searchString.ToLower(); //Filter Employee by Name var filteredList = employeeCollections.Where(x => (x.FirstName.ToLower()).Contains(string.IsNullOrEmpty(searchString) ? (x.FirstName.ToLower()) : searchString) || (x.LastName.ToLower()).Contains(string.IsNullOrEmpty(searchString) ? (x.LastName.ToLower()) : searchString) || (x.StaffNumber.ToLower()).Contains(string.IsNullOrEmpty(searchString) ? (x.StaffNumber.ToLower()) : searchString)); switch (sortOrder) { case "name_desc": filteredList = filteredList.OrderByDescending(s => s.LastName); break; case "Date": filteredList = filteredList.OrderBy(s => s.DateEmployed); break; case "date_desc": filteredList = filteredList.OrderByDescending(s => s.DateEmployed); break; default: filteredList = filteredList.OrderBy(s => s.LastName); break; } var companyDDL = GetDropDownList.CompanyListItems(companyCollection, -1); int pageSize = 10; int pageNumber = (page ?? 1); var returnedView = new EmployeeOnBoardListView { EmployeeList = filteredList.ToPagedList(pageNumber, pageSize), CompanyDropDown = companyDDL, sortOrder = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "", searchString = (searchString == "Date" ? "date_desc" : "Date"), ProcessingMessage = message, }; return(returnedView); }
public IEmployeeOnBoardListView CreateViewReport(IList <IEmployee> employee) { var result = new EmployeeOnBoardListView { employee = employee }; return(result); }
/// <summary> /// Creates the employee report. /// </summary> /// <param name="employeeCollections">The employee collections.</param> /// <param name="lastName">The last name.</param> /// <param name="firstName">The first name.</param> /// <param name="genderId">The gender identifier.</param> /// <param name="genderCollection">The gender collection.</param> /// <param name="employeeTypeId">The employee type identifier.</param> /// <param name="employmentTypeCollection">The employment type collection.</param> /// <param name="countryId">The country identifier.</param> /// <param name="countryCollection">The country collection.</param> /// <param name="stateOfOriginId">The state of origin identifier.</param> /// <param name="stateCollection">The state collection.</param> /// <param name="dateExitedFrom">The date exited from.</param> /// <param name="dateExitTo">The date exit to.</param> /// <param name="dateRetirementFrom">The date retirement from.</param> /// <param name="dateRetirementTo">The date retirement to.</param> /// <param name="dateOfBirthFrom">The date of birth from.</param> /// <param name="dateOfBirthTo">The date of birth to.</param> /// <param name="age">The age.</param> /// <param name="locationStateId">The location state identifier.</param> /// <param name="locationCountryId">The location country identifier.</param> /// <param name="page">The page.</param> /// <returns></returns> public IEmployeeOnBoardListView CreateEmployeeReport(IList <IEmployee> employeeCollections, string lastName, string firstName, int genderId, IList <IYourGender> genderCollection, int employeeTypeId, IList <IEmploymentType> employmentTypeCollection, int countryId, IList <ICountry> countryCollection, int stateOfOriginId, IList <IState> stateCollection, DateTime?dateExitedFrom, DateTime?dateExitTo, DateTime?dateRetirementFrom, DateTime?dateRetirementTo, DateTime?dateOfBirthFrom, DateTime?dateOfBirthTo, int age, int locationStateId, int locationCountryId, int?page, DateTime?dateEmployedFrom, DateTime?dateEmployedTo) { var stateDDL = GetDropDownList.StateListItem(stateCollection, -1); var genderDDL = GetDropDownList.GenderListItems(genderCollection, -1); var employeeTypeDDL = GetDropDownList.EmploymentTypeListItem(employmentTypeCollection, -1); var countryDDL = GetDropDownList.CountryListItem(countryCollection, -1); //Filter Employee by Name var filteredList = employeeCollections.Where(x => x.LastName.Contains(string.IsNullOrEmpty(lastName) ? x.LastName : lastName)).ToList(); filteredList = filteredList.Where(x => x.FirstName.Contains(string.IsNullOrEmpty(firstName) ? x.FirstName : firstName)).ToList(); filteredList = filteredList.Where(x => x.GenderId.Equals(genderId < 1 ? x.GenderId : genderId)).ToList(); filteredList = filteredList.Where(x => x.EmploymentTypeId.Equals(employeeTypeId < 1 ? x.EmploymentTypeId : employeeTypeId)).ToList(); filteredList = filteredList.Where(x => x.NationalityId.Equals(countryId < 1 ? x.NationalityId : countryId)).ToList(); filteredList = filteredList.Where(x => x.PermanentAddressStateId.Equals(stateOfOriginId < 1 ? x.PermanentAddressStateId : stateOfOriginId)).ToList(); filteredList = filteredList.Where(x => x.HomeAddressStateId.Equals(locationStateId < 1 ? x.HomeAddressStateId : locationStateId)).ToList(); foreach (var item in filteredList) { if ((item.DateExited >= dateExitedFrom && item.DateExited <= dateExitTo)) { filteredList = filteredList.Where((x => x.DateExited >= dateExitedFrom && x.DateExited <= dateExitTo)).ToList(); } else { filteredList = filteredList.Where(x => x.DateExited.Equals(x.DateExited)).ToList(); } if ((item.DateEmployed >= dateEmployedFrom && item.DateEmployed <= dateEmployedTo)) { filteredList = filteredList.Where((x => x.DateEmployed >= dateEmployedFrom && x.DateEmployed <= dateEmployedFrom)).ToList(); } else { filteredList = filteredList.Where(x => x.DateEmployed.Equals(x.DateEmployed)).ToList(); } if (item.Birthday >= dateOfBirthFrom && item.Birthday <= dateOfBirthTo) { filteredList = filteredList.Where((x => x.Birthday >= dateOfBirthFrom && x.Birthday <= dateOfBirthTo)).ToList(); } else { filteredList = filteredList.Where(x => x.Birthday.Equals(x.Birthday)).ToList(); } //if (ageFrom >= employeeAge && ageTo <= employeeAge) //{ // var employeeAge = (int) (DateTime.UtcNow - (DateTime)item.Birthday).Days * 0.00273973; // filteredList = filteredList.Where(x => employeeAge.Equals(age)).ToList(); //} } //filteredList = filteredList.Where(x => ((int)(DateTime.Now-(DateTime)x.Birthday).TotalDays / 365.25).Equals(age < 1 ? ((int)(DateTime.Now - (DateTime)x.Birthday).TotalDays / 365.25) : age)).ToList(); int pageSize = 10; int pageNumber = (page ?? 1); var result = new EmployeeOnBoardListView { EmployeeList = filteredList.ToPagedList(pageNumber, pageSize), GenderDropDown = genderDDL, StateDropDown = stateDDL, CountryDropDown = countryDDL, EmploymentTypeDropDown = employeeTypeDDL, SelectedGenderId = genderId, SelectedFirstName = firstName, SelectedLastName = lastName, SelectedCountryId = countryId, SelectedLocationStateId = locationStateId, SelectedStateOriginId = stateOfOriginId, SelectedEmploymentTypeId = employeeTypeId, SelectedDateExitFrom = dateExitedFrom, SelectedDateExitTo = dateExitTo, SelectedDateOfBirthFrom = dateOfBirthFrom, SelectedDateOfBirthTo = dateOfBirthTo }; return(result); }