public async Task <IActionResult> Index(int?page) { var pageNumber = page ?? 1; var pageSize = 10; var departments = (await _departmentServices.ListDepartmentsAsync()) .Select(department => new DepartmentListViewModel { Title = department.Title, Id = department.Id, DateAdded = department.DateTimeAdded == null ? string.Empty : DateTime.Parse(department.DateTimeAdded.ToString()).ToString("yyyy-MM-dd"), DateModified = department.DateTimeModified == null ? string.Empty : DateTime.Parse(department.DateTimeModified.ToString()).ToString("yyyy-MM-dd"), CreatedBy = department.UserAccount }).ToPagedList(pageSize, pageNumber); return(View(departments)); }
/// <summary> /// /// </summary> /// <returns></returns> private async Task LoadSelectListsAsync() { ViewData["DistrictSelectList"] = (await _districtServices.ListDistrictsAsync()) .Select(district => new SelectListItem { Text = district.Name, Value = district.Id.ToString() }); ViewData["ManagerSelectList"] = (await _employeeServices.ListEmployeesAsync()) .Where(emp => emp.IsActive) .Select(employee => new SelectListItem { Text = employee.FirstName + ',' + ' ' + employee.LastName, Value = employee.Id.ToString() }); ViewData["DepartmentSelectList"] = (await _departmentServices.ListDepartmentsAsync()) .Select(department => new SelectListItem { Text = department.Title, Value = department.Id.ToString() }); ViewData["NationalitySelectList"] = (await _nationalityServices.ListNationalitiesAsync()) .Select(nationality => new SelectListItem { Text = nationality.Description, Value = nationality.Id.ToString() }); ViewData["BankSelectList"] = (await _bankServices.ListBankAsync()) .Select(bank => new SelectListItem { Text = bank.Name, Value = bank.Id.ToString() }); //ViewData["RelationshipSelectList"] = (await _relationshipTypeServices.ListRelationshipsAsync()) // .Select(relationship => new SelectListItem // { // Text = relationship.Title, // Value = relationship.Id.ToString() // }); }
/// <summary> /// /// </summary> /// <returns></returns> private async Task LoadSelectListsAsync() { ViewData["DistrictSelectList"] = (await _districtServices.ListDistrictsAsync()) .Select(district => new SelectListItem { Text = district.Name, Value = district.Id.ToString() }); ViewData["EmployeeSelectList"] = (await _employeeServices.ListEmployeesAsync()) .Select(employee => new SelectListItem { Text = employee.FirstName + ',' + ' ' + employee.LastName, Value = employee.Id.ToString() }); ViewData["DepartmentSelectList"] = (await _departmentServices.ListDepartmentsAsync()) .Select(department => new SelectListItem { Text = department.Title, Value = department.Id.ToString() }); }