Ejemplo n.º 1
0
        public void GetUsersToVehicle(Vehicle vehicle)
        {
            vehiclesViewModel.VehicleToEmployeeRelations.Clear();

            var relation = socket.GetRelationFromVehicle(vehicle);

            if (relation != null)
            {
                foreach (var rel in relation)
                {
                    vehiclesViewModel.VehicleToEmployeeRelations.Add(rel);
                }
            }
        }
Ejemplo n.º 2
0
        public VehicleToEmployeeRelation AddRelation(FleetServiceClient socket, Vehicle vehicle)
        {
            addRelationWindow = new AddRelationWindow();

            //Filter wich Employees get shown
            List <Employee> emps = socket.GetAllEmployees().ToList();
            List <VehicleToEmployeeRelation> rels = socket.GetRelationFromVehicle(vehicle).ToList();
            List <Employee> selectedEmps          = new List <Employee>(emps);

            emps.ForEach(emp =>
            {
                if (rels.Find(rel => rel.EmployeeId.Id == emp.Id) != null)
                {
                    selectedEmps.Remove(emp);
                }
            });

            addRelationViewModel = new AddRelationViewModel()
            {
                AddCommand    = new RelayCommand(ExecuteAddCommand),
                CancelCommand = new RelayCommand(ExecuteCancelCommand),
                Employees     = new ObservableCollection <Employee>(selectedEmps),
                Vehicle       = vehicle
            };
            addRelationWindow.DataContext = addRelationViewModel;

            if (addRelationWindow.ShowDialog() == true)
            {
                var relation = addRelationViewModel.Relation;
                relation.EmployeeId = addRelationViewModel.SelectedEmployee;
                relation.VehicleId  = vehicle;
                return(relation);
            }
            else
            {
                return(null);
            }
        }