Пример #1
0
 public override ViewModelBase Initialize()
 {
     employeeAreaViewModel = new EmployeesViewModel()
     {
         Employees            = new ObservableCollection <Employee>(socket.GetAllEmployees()),
         entryEmployees       = socket.GetAllEmployees().ToList(),
         SelectedEmployee     = null,
         BusinessUnits        = new ObservableCollection <BusinessUnit>(socket.GetAllBusinessUnits()),
         SelectedBusinessUnit = null
     };
     return(employeeAreaViewModel);
 }
Пример #2
0
 public IEnumerable <CostBusinessAreaModel> GetCostsPerMonthPerBusinessUnit() => socket.GetAllBusinessUnits()
 .Join(socket.GetAllEmployees(), b => b.Id, e => e.BusinessUnitId.Id, (b, e) => new { BusinessUnit = b, Employee = e })
 .Join(socket.GetAllRelations(), be => be.Employee.Id, ve => ve.EmployeeId.Id, (be, ve) => new { BusinessUnitEmployee = be, VehicleEmployee = ve })
 .Join(socket.GetAllVehicles(), beve => beve.VehicleEmployee.VehicleId.Id, v => v.Id, (beve, v) => new { beve.BusinessUnitEmployee.BusinessUnit, beve.VehicleEmployee, Vehicle = v })
 .Select(m => new { m.BusinessUnit, Costs = GetCostsPerVehicle(m.VehicleEmployee, m.Vehicle) })
 .SelectMany(bv => bv.Costs.Select(c => new { VehicleCost = c, bv.BusinessUnit }))
 .GroupBy(cb => new { cb.VehicleCost.Month, cb.BusinessUnit })
 .Select(cb => new CostBusinessAreaModel()
 {
     Month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(cb.Key.Month.Month) + " " + cb.Key.Month.Year, BusinessUnit = cb.Key.BusinessUnit, Costs = cb.Sum(c => c.VehicleCost.Costs), CostDisplay = string.Format("€ {0}", cb.Sum(c => c.VehicleCost.Costs).ToString("0.00"))
 });
Пример #3
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);
            }
        }
Пример #4
0
        public VehicleToEmployeeRelation AddRelation(FleetServiceClient socket, Vehicle vehicle)
        {
            addRelationWindow    = new AddRelationWindow();
            addRelationViewModel = new AddRelationViewModel()
            {
                AddCommand    = new RelayCommand(ExecuteAddCommand),
                CancelCommand = new RelayCommand(ExecuteCancelCommand),
                Employees     = new ObservableCollection <Employee>(socket.GetAllEmployees()),
                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);
            }
        }
Пример #5
0
        private void ExecuteOpenEmployeesCommand(object obj)
        {
            var employeesViewController = new EmployeesViewController();

            fleetManagementViewModel.NewCommand    = new RelayCommand(ExecuteNewEmployeeCommand);
            fleetManagementViewModel.SaveCommand   = new RelayCommand(ExecuteSaveEmployeeCommand);
            fleetManagementViewModel.DeleteCommand = new RelayCommand(ExecuteDeleteEmployeeCommand);

            fleetManagementViewModel.ActiveViewModel = employeesViewController.Initialize();
            (fleetManagementViewModel.ActiveViewModel as EmployeesViewModel).Employees     = new ObservableCollection <Employee>(socket.GetAllEmployees());
            (fleetManagementViewModel.ActiveViewModel as EmployeesViewModel).BusinessUnits = socket.GetAllBusinessUnits().ToList();

            //Persist Entry State Employees
            (fleetManagementViewModel.ActiveViewModel as EmployeesViewModel).entryEmployees = (fleetManagementViewModel.ActiveViewModel as EmployeesViewModel).Employees.ToList();
        }