public override ViewModelBase Initialize() { businessAreaViewModel = new BusinessAreasViewModel() { BusinessAreas = new ObservableCollection <BusinessUnit>(socket.GetAllBusinessUnits()), entryBusinessArea = socket.GetAllBusinessUnits().ToList() }; return(businessAreaViewModel); }
public override ViewModelBase Initialize() { employeeAreaViewModel = new EmployeesViewModel() { Employees = new ObservableCollection <Employee>(socket.GetAllEmployees()), SelectedEmployee = null, BusinessUnits = new ObservableCollection <BusinessUnit>(socket.GetAllBusinessUnits()), SelectedBusinessUnit = null }; return(employeeAreaViewModel); }
public Employee AddEmployee(FleetServiceClient socket) { addEmployeeWindow = new AddEmployeeWindow(); addEmployeeViewModel = new AddEmployeeViewModel() { AddCommand = new RelayCommand(ExecuteAddCommand), BusinessUnits = socket.GetAllBusinessUnits().ToList() }; addEmployeeWindow.DataContext = addEmployeeViewModel; return(addEmployeeWindow.ShowDialog() == true ? addEmployeeViewModel.Employee : null); }
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(); }
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")) });