예제 #1
0
        private async Task LoadRatings(int vehicleId = 0)
        {
            var ratings = await _ratingService.Get <List <RatingModel> >(null);

            var vehicleModels = await _vehicleModelService.Get <List <VehicleModelModel> >(null);

            var persons = await _personService.Get <List <PersonModel> >(null);

            var vehicles = await _vehicleService.Get <List <OpenRoads.Model.VehicleModel> >(null);

            var clients = await _clientService.Get <List <ClientModel> >(null);

            if (vehicleId != 0)
            {
                OpenRoads.Model.VehicleModel vehicle = await _vehicleService.GetById <OpenRoads.Model.VehicleModel>(vehicleId);

                var clientsList  = generateClientsToDisplay(persons, clients);
                var vehiclesList = generateVehiclesToDisplay(vehicleModels, vehicles, vehicle);

                var ratingsList = GenerateResult(vehiclesList, clientsList, ratings);

                dgvRatings.AutoGenerateColumns = false;
                dgvRatings.DataSource          = ratingsList;
            }

            else
            {
                var vehiclesList = generateVehiclesToDisplay(vehicleModels, vehicles, null);
                var clientsList  = generateClientsToDisplay(persons, clients, null);

                var ratingsList = GenerateResult(vehiclesList, clientsList, ratings);

                dgvRatings.AutoGenerateColumns = false;
                dgvRatings.DataSource          = ratingsList;
            }
        }
예제 #2
0
        private List <VehiclesToDisplay> generateVehiclesToDisplay(List <VehicleModelModel> vehicleModels,
                                                                   List <OpenRoads.Model.VehicleModel> vehicles = null, OpenRoads.Model.VehicleModel vehicle = null)
        {
            var vehiclesList = new List <VehiclesToDisplay>();

            if (vehicle != null)
            {
                foreach (var x in vehicles)
                {
                    if (x.VehicleId == vehicle.VehicleId)
                    {
                        foreach (var y in vehicleModels)
                        {
                            if (x.VehicleModelId == y.VehicleModelId)
                            {
                                vehiclesList.Add(new VehiclesToDisplay
                                {
                                    VehicleName = y.Name,
                                    VehicleId   = x.VehicleId
                                });
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (var x in vehicles)
                {
                    foreach (var y in vehicleModels)
                    {
                        if (x.VehicleModelId == y.VehicleModelId)
                        {
                            vehiclesList.Add(new VehiclesToDisplay
                            {
                                VehicleName = y.Name,
                                VehicleId   = x.VehicleId
                            });
                            break;
                        }
                    }
                }
            }

            return(vehiclesList);
        }