Esempio n. 1
0
        public IActionResult GetVehicles(int id)
        {
            var vehicleData   = new VehicleData();
            var conPairModels = new ConstantPair();
            var conPairMakes  = new ConstantPair();

            var vehicleList = vehicle.GetVehicleById(id);

            var vmodels = makes.FindModels(vehicleList.ModelId);

            conPairModels.Id   = vmodels.Id;
            conPairModels.Name = vmodels.Name;

            var vmakes = makes.GetMakeById(vmodels.Make.Id);

            conPairMakes.Id   = vmakes.Id;
            conPairMakes.Name = vmakes.Name;


            var cont = new ContactResource();

            cont.ContactEmail        = vehicleList.ContactEmail;
            cont.ContactName         = vehicleList.ContactName;
            cont.ContactPhone        = vehicleList.ContactPhone;
            vehicleData.Features     = getFeatures(vehicleList.Features);
            vehicleData.isRegistered = vehicleList.isRegistered;
            vehicleData.LastUpdated  = vehicleList.LastUpdated;
            vehicleData.Contact      = cont;
            vehicleData.Model        = conPairModels;
            vehicleData.Make         = conPairMakes;
            return(Ok(vehicleData));
        }
Esempio n. 2
0
        public ICollection <ConstantPair> getFeatures(ICollection <VehicleFeature> vehicleFeatures)
        {
            ICollection <ConstantPair> intList = new Collection <ConstantPair>();

            foreach (var item in vehicleFeatures)
            {
                ConstantPair featureResource = new ConstantPair();

                featureResource.Id   = item.Feature.Id;
                featureResource.Name = item.Feature.Name;
                intList.Add(featureResource);
            }
            return(intList);
        }
Esempio n. 3
0
        public ICollection <ConstantPair> getModel(ICollection <Models> models)
        {
            ICollection <ConstantPair> modelResourceList = new Collection <ConstantPair>();

            foreach (var item in models)
            {
                var modelResource = new ConstantPair();

                modelResource.Id   = item.Id;
                modelResource.Name = item.Name;
                modelResourceList.Add(modelResource);
            }
            return(modelResourceList);
        }