public IActionResult Index(EmployeeFilter employeeFilter)
        {
            ViewBag.Name = employeeFilter.Name;
            ViewBag.CPF  = employeeFilter.CPF;
            var employees = _employeeRest.FindPaginated(employeeFilter);

            return(View(employees));
        }
Example #2
0
        public IActionResult Index(int currentPage, Occupation occupation, long vehicleId)
        {
            ViewBag.OcccupationSelected = occupation;

            var membersWorking = _memberRest.FindAll(new MemberFilter {
                EmployeeStatus = EmployeeStatus.Working
            }).Model;

            var membersGuidWorking = membersWorking
                                     .Select(d => d.EmployeeGuid).Distinct()
                                     .ToList();

            var employees = _employeeRest.FindPaginated(new EmployeeFilter
            {
                Occupation          = occupation,
                EmployeeGuidWorking = membersGuidWorking,
                IsMember            = true,
                CurrentPage         = currentPage == 0 ? 1 : currentPage
            });

            var vehicles = _vehicleRest.FindAll(new VehicleFilter());

            var currentVehicle = vehicles.Model.FirstOrDefault();

            if (vehicleId > 0)
            {
                currentVehicle = vehicles.Model.FirstOrDefault(d => d.Id == vehicleId);
            }

            ViewBag.VehicleId = currentVehicle.Id;

            List <EmployeeVehicleModel> employeeVehicles = new List <EmployeeVehicleModel>();

            foreach (var memberWorking in membersWorking.Where(d => d.VehicleId == currentVehicle.Id))
            {
                var employee = _employeeRest.Find(new EmployeeFilter {
                    Guid = memberWorking.EmployeeGuid
                }).Model;
                if (employee != null)
                {
                    EmployeeVehicleModel employeeVehicleModel = new EmployeeVehicleModel
                    {
                        EmployeeModel = employee,
                        VehicleModel  = currentVehicle,
                        MemberId      = memberWorking.Id
                    };
                    employeeVehicles.Add(employeeVehicleModel);
                }
            }

            return(View(new MemberRegisterModel {
                EmployeeModels = employees, VehicleModels = vehicles.Model, EmployeeVehicleModels = employeeVehicles
            }));
        }