Beispiel #1
0
        public VehicleData Create(Vehicle vehicle)
        {
            var vehicleData = new VehicleData
            {
                Brand = vehicle.Brand,
                Color = vehicle.Color,
                NumberPlate = vehicle.NumberPlate,
                AdditionalFeatures = vehicle.AdditionalFeatures
            };

            return vehicleData;
        }
Beispiel #2
0
        public VehicleData Create(Vehicle vehicle)
        {
            var vehicleData = new VehicleData
            {
                Brand              = vehicle.Brand,
                Color              = vehicle.Color,
                NumberPlate        = vehicle.NumberPlate,
                AdditionalFeatures = vehicle.AdditionalFeatures
            };

            return(vehicleData);
        }
Beispiel #3
0
        private VehicleData Modify(VehicleData vehicleData, JToken json)
        {
            var data = vehicleData ?? new VehicleData();

            data.AdditionalFeatures = json["additionalFeatures"] != null?json.Value <string>("additionalFeatures") : data.AdditionalFeatures;

            data.Brand = json["brand"] != null?json.Value <string>("brand") : data.Brand;

            data.Color = json["color"] != null?json.Value <string>("color") : data.Color;

            data.NumberPlate = json["numberPlate"] != null?json.Value <string>("numberPlate") : data.NumberPlate;

            return(data);
        }
Beispiel #4
0
        private ICollection <VehicleData> ModifyVehicles(JToken json)
        {
            var vehicles = new List <VehicleData>();

            foreach (var vehicleJson in json)
            {
                var vehicle = new VehicleData
                {
                    Brand = vehicleJson.Value <string>("brand"),
                    AdditionalFeatures = vehicleJson.Value <string>("additionalFeatures"),
                    Color       = vehicleJson.Value <string>("color"),
                    NumberPlate = vehicleJson.Value <string>("numberPlate")
                };

                var vehicleType = new CultureInfo("en-US", false).TextInfo.ToTitleCase(vehicleJson.Value <string>("vehicleType") ?? "Other");

                vehicle.VehicleType = (VehicleTypeEnum)Enum.Parse(typeof(VehicleTypeEnum), vehicleType);

                vehicles.Add(vehicle);
            }

            return(vehicles);
        }
Beispiel #5
0
        private VehicleData Modify(VehicleData vehicleData, JToken json)
        {
            var data = vehicleData ?? new VehicleData();
            data.AdditionalFeatures = json["additionalFeatures"] != null ? json.Value<string>("additionalFeatures") : data.AdditionalFeatures;
            data.Brand = json["brand"] != null ? json.Value<string>("brand") : data.Brand;
            data.Color = json["color"] != null ? json.Value<string>("color") : data.Color;
            data.NumberPlate = json["numberPlate"] != null ? json.Value<string>("numberPlate") : data.NumberPlate;

            var vehicleTypeString = json["vehicleType"] != null ? json.Value<string>("vehicleType") : null;
            data.VehicleType = vehicleTypeString != null ? (VehicleTypeEnum) Enum.Parse(typeof (VehicleTypeEnum), vehicleTypeString, true) : VehicleTypeEnum.Other;

            return data;
        }
Beispiel #6
0
 public VehicleData Modify(VehicleData vehicleData, JToken json)
 {
     var data = vehicleData ?? new VehicleData();
     data.AdditionalFeatures = json["additionalFeatures"] != null ? json.Value<string>("additionalFeatures") : data.AdditionalFeatures;
     data.Brand = json["brand"] != null ? json.Value<string>("brand") : data.Brand;
     data.Color = json["color"] != null ? json.Value<string>("color") : data.Color;
     data.NumberPlate = json["numberPlate"] != null ? json.Value<string>("numberPlate") : data.NumberPlate;
     return data;
 }