Ejemplo n.º 1
0
        public async Task <IActionResult> Index(int?page)
        {
            var pageNumber = page ?? 1;
            var pageSize   = 10;
            var model      = (await _nationalityServices.ListNationalitiesAsync())
                             .Select(nationality => new NationalityListViewModel
            {
                Id           = nationality.Id,
                Description  = nationality.Description,
                DateAdded    = nationality.DateTimeAdded == null ? string.Empty : DateTime.Parse(nationality.DateTimeAdded.ToString()).ToString("yyyy-MM-dd"),
                DateModified = nationality.DateTimeModified == null ? string.Empty : DateTime.Parse(nationality.DateTimeModified.ToString()).ToString("yyyy-MM-dd"),
                CreatedBy    = nationality.UserAccount
            }).ToPagedList(pageSize, pageNumber);

            return(View(model));
        }
Ejemplo n.º 2
0
        /// <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()
            //   });
        }