Пример #1
0
        // GET: Companies
        public ActionResult Index(EmployeeToSearch search, string Sorting_Order)
        {
            var ListOfEmployeesToView = _employeeService.GetEmployees(search, Sorting_Order);

            ViewBag.Employees = ListOfEmployeesToView;

            var ListOfEmployeesTypes = _employeeTypeService.GetEmployeeTypesToSortDDL();

            ViewBag.EmployeesTypes = ListOfEmployeesTypes;

            var ListOfCompaniesToView = _companyService.GetCompaniesToSortDDL();

            ViewBag.Companies = ListOfCompaniesToView;

            ViewBag.Count = ListOfEmployeesToView.Count();

            return(View(search));
        }
Пример #2
0
        public List <EmployeeToView> GetEmployees(EmployeeToSearch search, string sortingOrder)
        {
            Dictionary <string, string> Filter = new Dictionary <string, string>();

            // TO DO: ClearFilter

            if (sortingOrder == OrderBy)
            {
                Direction = Direction != "ASC" ? "ASC" : "DESC";
            }
            else
            {
                OrderBy   = sortingOrder;
                Direction = "ASC";
            }

            foreach (var property in search.GetType().GetProperties())
            {
                var value = property.GetValue(search);
                if (value != null)
                {
                    Filter.Add(property.Name, value.ToString());
                }
            }

            var employee        = new Employee();
            var ListOfEmployees = Converters.ConvertDataTable <Employee>(_repositoryManager.Employee.GetEmployeesByCondition(employee, OrderBy, Direction, Filter).Tables[0]);

            var ListOfEmployeesToView = Mapper.MapCollection <EmployeeToView, Employee>(ListOfEmployees, new Dictionary <string, KeyValuePair <string, Delegate> >()
            {
                { "EmployeeTypeName", new KeyValuePair <string, Delegate>("TypeId", new Func <Employee, string, string>(EmployeeHelper.GetEmployeeTypeName)) },
                { "EmployeeCompanyName", new KeyValuePair <string, Delegate>("CompanyId", new Func <Employee, string, string>(EmployeeHelper.GetEmployeeCompanyName)) }
            }).ToList();

            return(ListOfEmployeesToView);
        }