public override ViewModelBase Initialize() { vehiclesViewModel = new VehiclesViewModel() { Vehicles = new ObservableCollection <Vehicle>(socket.GetAllVehicles()), entryVehicles = socket.GetAllVehicles().ToList(), AddEmployeeToVehicle = new RelayCommand(ExecuteAddEmployeeToVehicleCommand), RemoveEmployeeFromVehicle = new RelayCommand(ExecuteRemoveEmployeeFromVehicleCommand), vehiclesViewController = this }; return(vehiclesViewModel); }
private List <CostMontlyModel> GetData() { var costMontly = new List <CostMontlyModel>(); var vehicles = socket.GetAllVehicles(); foreach (var vehicle in vehicles) { for (var iterator = vehicle.LeasingFrom; iterator < vehicle.LeasingTo; iterator = iterator.AddMonths(1)) { costMontly.Add(new CostMontlyModel() { Month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(iterator.Month) + " " + iterator.Year, Amount = 1, Cost = vehicle.Insurance / 12 + vehicle.LeasingRate, CostDisplay = "" }); } } costMontly = costMontly .GroupBy(cm => cm.Month) .Select(gcm => new CostMontlyModel() { Month = gcm.Key, Amount = gcm.Count(), Cost = gcm.Sum(x => x.Cost), CostDisplay = string.Format("€ {0}", gcm.Sum(z => z.Cost).ToString("0.00")) } ).OrderByDescending(x => x.Cost).ToList(); return(costMontly); }
private List <CostMontlyModel> GetData() { var costMontly = new List <CostMontlyModel>(); var vehicles = socket.GetAllVehicles(); //FilterOperations //var amountVehiclesJanuary = (from vehicle in vehicles // where vehicle.LeasingFrom.Month <= 1 && vehicle.LeasingTo.Month >= 1 // select (vehicle.Id)).Count(); // //var costVehiclesJanuary = (from vehicle in vehicles // where vehicle.LeasingFrom.Month <= 1 && vehicle.LeasingTo.Month >= 1 // select (vehicle.Insurance)).Sum(); foreach (var vehicle in vehicles) { //Operations costMontly.Add(new CostMontlyModel() { Month = "Januar", Amount = vehicle.Insurance, Cost = vehicle.Insurance }); } return(costMontly);; }
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")) });