Esempio n. 1
0
        public ActionResult Park(string Regnr, VehicleType Type, Color Color, string Brand, int NrofWheels, double Length, FuelType FuelType)
        {
            if (db.Vehicles.Any(v => v.Regnr == Regnr))
            {
                return(RedirectToAction("Register"));
            }

            ParkedVehicle vehicle = new ParkedVehicle()
            {
                Regnr      = Regnr.ToUpper(),
                Type       = Type.ToString(),
                Color      = Color.ToString(),
                Brand      = Brand,
                NrofWheels = NrofWheels,
                Length     = Length,
                FuelType   = FuelType.ToString(),
                ParkedTime = DateTime.Now
            };

            if (ModelState.IsValid)
            {
                db.Vehicles.Add(vehicle);
                db.SaveChanges();
            }

            return(View(vehicle));
        }
Esempio n. 2
0
        private void CalculateInfo()
        {
            string[] infoArr =
            {
                "MOT",            MOT.ToString(),
                "Sat Nav",        SatNav.ToString(),
                "Locked",         Locked.ToString(),
                "Manufacturer",   Manufacturer,
                "Model",          Model,
                "Wheels",         Wheels.ToString(),
                "Gears",          Gears.ToString(),
                "Fuel Level",     FuelLevel.ToString(),
                "Fuel Type",      FuelType.ToString(),
                "EngineCC",       Engine.EngineCC.ToString(),
                "Mileage",        Engine.Mileage.ToString(),
                "Service Needed", Engine.ServiceNeeded.ToString()
            };

            for (int i = 0; i < infoArr.Length; i++)
            {
                Info = Info + infoArr[i] + ": ";
                i++;
                Info = Info + infoArr[i] + "\n";
            }
        }
Esempio n. 3
0
 public override string ToString()
 {
     return(string.Format(
                "{0} car with {1} max speed and {2} seats}",
                FuelType.ToString(),
                MaxSpeed.ToString(),
                SeatCount.ToString()));
 }
Esempio n. 4
0
 public override string ToString()
 {
     return("\nEconomy Class Car Details:" +
            "\nVehicle Rego: " + vehicleRego.ToString() + "\nVehicle Class: " + vehicleClass.ToString()
            + "\nMake: " + make.ToString() + "\nModel: " + model.ToString() + "\nYear: " + year.ToString()
            + "\nNumber of seats: " + numSeats.ToString() + "\nTransmission Type: " + transmissionType.ToString()
            + "\nFuel Type: " + fuelType.ToString() + "\nGPS: " + gps.ToString() + "\nsunRoof: " + sunRoof.ToString()
            + "\nDaily Rate: " + dailyRate.ToString("C2") + "\nColour: " + colour.ToString() + "\n\n");
 }
Esempio n. 5
0
        /// <summary>
        /// Returns fuel name & ID
        /// </summary>
        /// <param name="f">The propellant</param>
        /// <returns></returns>
        public static string GetFuelName(FuelType f)
        {
            switch (f)
            {
            case FuelType.IRFNA_III:
                return("IRFNA-III");

            case FuelType.IRFNA_IV:
                return("IRFNA-III");

            default:
                return(f.ToString());
            }
        }
Esempio n. 6
0
        public override string                  ToString()
        {
            StringBuilder gasVehicalDetails = new StringBuilder();

            gasVehicalDetails.AppendLine(string.Format(
                                             @"Gas Engine Properties:
Fuel type: {0}
Max gas tank capacity: {1}L
Current gas volume: {2}L",
                                             FuelType.ToString(),
                                             MaxCapacity,
                                             CurrentCapacity));

            return(gasVehicalDetails.ToString());
        }
Esempio n. 7
0
        public List <string> GetAttributeList()
        {
            bool _GPS     = true;
            bool _sunRoof = true;
            //Create new list of vehicle attributes
            List <string> VehicleAttributes = new List <string>();

            string regoAttr         = _vehicleRego.ToString();
            string makeAttr         = _make.ToString();
            string modelAttr        = _model.ToString();
            string yearAttr         = _year.ToString();
            string vehicleClassAttr = _vehicleClass.ToString();
            string numSeatsAttr     = _numSeats.ToString() + "-Seater";
            string transmissionAttr = _transmissionType.ToString();
            string fuelAttr         = _fuelType.ToString();
            string gpsAttr          = "GPS";
            string sunroofAttr      = "Sunroof";
            string dailyRateAttr    = _dailyRate.ToString();
            string colourAttr       = _colour.ToString();

            //Add strings to list
            VehicleAttributes.Add(regoAttr);
            VehicleAttributes.Add(makeAttr);
            VehicleAttributes.Add(modelAttr);
            VehicleAttributes.Add(yearAttr);
            VehicleAttributes.Add(vehicleClassAttr);
            VehicleAttributes.Add(numSeatsAttr);
            VehicleAttributes.Add(transmissionAttr);
            VehicleAttributes.Add(fuelAttr);
            VehicleAttributes.Add(dailyRateAttr);
            VehicleAttributes.Add(colourAttr);

            //Only Add GPS and Sunroof if true
            if (_GPSat)
            {
                VehicleAttributes.Add(gpsAttr);
            }
            if (_sunRoofat)
            {
                VehicleAttributes.Add(sunroofAttr);
            }

            for (int i = 0; i < VehicleAttributes.Count; i++)
            {
                Console.WriteLine(VehicleAttributes[i]);
            }
            return(VehicleAttributes);
        }
Esempio n. 8
0
        public Fuel GetFuelByTypeAndGrade(FuelType fuelType, FuelGrade fuelGrade)
        {
            var fuel = Context.Fuels.SingleOrDefault(f => f.FuelType == fuelType && f.FuelGrade == fuelGrade);

            if (fuel == null)
            {
                fuel = new Fuel()
                {
                    FuelType = fuelType, FuelGrade = fuelGrade, FuelName = fuelType.ToString() + fuelGrade.ToString()
                }
            }
            ;

            return(fuel);
        }
    }
Esempio n. 9
0
        public static string ToDisplayName(this FuelType fuelType)
        {
            switch (fuelType)
            {
            case FuelType.Pb95: return("Pb95");

            case FuelType.Pb98: return("Pb98");

            case FuelType.Diesel: return("ON");

            case FuelType.DieselPremium: return("ON+");

            case FuelType.Gas: return("LPG");

            default: return(fuelType.ToString());
            }
        }
Esempio n. 10
0
        public string ToCSVString()
        {
            paramters.Add(vehicleRego);
            paramters.Add(make);
            paramters.Add(model);
            paramters.Add(year.ToString());
            paramters.Add(vehicleClass.ToString());
            paramters.Add(numSeats.ToString());
            paramters.Add(transmission.ToString());
            paramters.Add(fuelType.ToString());
            paramters.Add(GPS.ToString());
            paramters.Add(sunRoof.ToString());
            paramters.Add(colour);
            paramters.Add(dailyRate.ToString());
            string CSV = String.Join(",", paramters);

            return(CSV);
        }
Esempio n. 11
0
        public dynamic ToJson()
        {
            dynamic json = new
            {
                packetType = nameof(CarMessage),
                data       = new
                {
                    carId          = Car.CarID,
                    carBrand       = Car.Brand,
                    carModel       = Car.Model,
                    carDescription = Car.Description,
                    carMileage     = Car.Mileage,
                    carColor       = Car.Color,
                    carYear        = Car.Year,
                    carStatus      = Status.ToString(),
                    carFuelType    = FuelType.ToString()
                }
            };

            return(JsonConvert.SerializeObject(json));
        }
Esempio n. 12
0
        }        // end of previous method - ToString()

        // ---------------------------------------------------------------------

        /// <summary>
        /// This method should return a list of strings which represent each attribute. Values
        /// should be made to be unique, e.g.numSeats should not be written as ‘4’ but as ‘4-
        /// Seater’, sunroof should not be written as ‘True’ but as ‘sunroof’ or with no string
        /// added if there is no sunroof.Vehicle rego, class, make, model, year, transmission
        /// type, fuel type, daily rate, and colour can all be assumed to not overlap(i.e. if
        /// the make ‘Mazda’ exists, ‘Mazda’ will not exist in other attributes e.g.there is
        /// no model named ‘Mazda’. Similarly, if the colour ‘red’ exists, there is no ‘red’
        /// make.You do not need to maintain this restriction, only assume it is true.)
        /// </summary>
        public List <string> GetAttributeList()
        {
            List <string> attributes = new List <string>();

            attributes.Add(VehicleRego);
            attributes.Add(Make);
            attributes.Add(Model);
            attributes.Add(Year.ToString());
            attributes.Add(VehicleClass.ToString());
            attributes.Add(NumSeats + "-Seater");
            attributes.Add(TransmissionType.ToString());
            attributes.Add(EngineSize + "-Cylinder");
            attributes.Add(Turbo.ToString());
            attributes.Add(FuelType.ToString());
            attributes.Add(GPS.ToString());
            attributes.Add(SunRoof.ToString());
            attributes.Add(Colour);
            attributes.Add(DailyRate.ToString());

            return(attributes);
        }        // end of previous method - GetAttributeList()
Esempio n. 13
0
 public string GetModuleInfo()
 {
     return($"Fuel Type: {FuelType.ToString()}\nH To Thrust: {HToThrust}\nV To Thrust: {VToThrust}");
 }
        private Good mapOffhireDataGoodToOffhireSystemEntity(FuelType fuelType, long companyId)
        {
            var goodCode = OffhireAssetsToFuelAssetsMapper.GetFuelGoodCode(fuelType.ToString());

            var good = goodRepository.Single(g => g.CompanyId == companyId && g.Code == goodCode);

            return good;
        }
Esempio n. 15
0
 //Coverts a vehicle into a string which each attribute separated by a space
 public override string ToString()
 {
     return(vehicleRego + " " + make + " " + model + " " + year.ToString() + " " + vehicleClass.ToString() +
            " " + numSeats.ToString() + " " + transmission.ToString() + " " + fuel.ToString() + " " +
            GPS.ToString() + " " + sunRoof.ToString() + " " + colour + " " + dailyRate.ToString());
 }
Esempio n. 16
0
 public static string QueryString(this FuelType fuelType)
 {
     return(fuelType.ToString().ToLower());
 }
Esempio n. 17
0
        public static void StartRefill(Client client, OwnedVehicle ownedVehicle, FuelType fuelType)
        {
            if (!client.hasData("player"))
            {
                return;
            }
            Player player = client.getData("player");

            if (ownedVehicle.ActiveHandle.engineStatus)
            {
                API.shared.sendNotificationToPlayer(client, "~r~You must first turn off the engine before you start refuel.");
                return;
            }
            GasStation gasStation = GasStationList.FirstOrDefault(x => x.Position.DistanceTo(client.position) <= 20);

            client.setData("gasStation", gasStation);
            if (gasStation == null)
            {
                return;
            }

            if (VehicleService.GetVehicleInfo(ownedVehicle.ModelName).Fuel != fuelType)
            {
                API.shared.sendNotificationToPlayer(client, "~o~You don't wont fill " + fuelType.ToString() + " in your " + ownedVehicle.ModelName + "(" +
                                                    VehicleService.GetVehicleInfo(ownedVehicle.ModelName).Fuel.ToString() + ").. ~r~~n~Remember that..");
                return;
            }

            int    maxFuel   = VehicleService.GetVehicleInfo(ownedVehicle.ModelName).MaxFuel;
            int    startFuel = ownedVehicle.Fuel;
            double price     = 0;

            switch (fuelType)
            {
            case FuelType.Petrol:
                price = gasStation.StationFuelPrices.Petrol;
                break;

            case FuelType.Diesel:
                price = gasStation.StationFuelPrices.Diesel;
                break;

            case FuelType.Gas:
                price = gasStation.StationFuelPrices.Gas;
                break;

            case FuelType.Electricity:
                price = gasStation.StationFuelPrices.Electricity;
                break;

            case FuelType.Kerosene:
                price = gasStation.StationFuelPrices.Kerosene;
                break;
            }

            API.shared.triggerClientEvent(client, "ShowRefuelProgressbar", ownedVehicle.Fuel, maxFuel);
            client.setData("fuelStartPosition", client.position);
            client.setSyncedData("currentfuel", ownedVehicle.Fuel);
            client.setData("fuelcar", ownedVehicle);
            client.setData("fuelcarstart", ownedVehicle.Fuel);
            client.setData("fueltype", fuelType);
            Timer timer = API.shared.startTimer(1000, false, () => {
                if (ownedVehicle.Fuel < VehicleService.GetVehicleInfo(ownedVehicle.ModelName).MaxFuel)
                {
                    Vector3 startPositon = client.getData("fuelStartPosition");
                    if (startPositon.DistanceTo(client.position) > 4f)
                    {
                        StopRefill(client);
                        return;
                    }

                    switch (fuelType)
                    {
                    case FuelType.Petrol:
                        if (gasStation.Storage.Petrol > 0)
                        {
                            gasStation.Storage.Petrol--;
                        }
                        else
                        {
                            StopRefill(client);
                            API.shared.sendNotificationToPlayer(client, "~o~This gas station has no more ~b~Petrol~o~ in stock..");
                            return;
                        }
                        break;

                    case FuelType.Diesel:
                        if (gasStation.Storage.Diesel > 0)
                        {
                            gasStation.Storage.Diesel--;
                        }
                        else
                        {
                            StopRefill(client);
                            API.shared.sendNotificationToPlayer(client, "~o~This gas station has no more ~b~Diesel~o~ in stock..");
                            return;
                        }
                        break;

                    case FuelType.Gas:
                        if (gasStation.Storage.Gas > 0)
                        {
                            gasStation.Storage.Gas--;
                        }
                        else
                        {
                            StopRefill(client);
                            API.shared.sendNotificationToPlayer(client, "~o~This gas station has no more ~b~Gas~o~ in stock..");
                            return;
                        }
                        break;
                    }

                    if (player.Character.Bank < GetFuelPrice(gasStation, fuelType))
                    {
                        StopRefill(client);
                        API.shared.sendNotificationToPlayer(client, "~r~You don't have enough Money to continue the Refuel..");
                        return;
                    }


                    ownedVehicle.Fuel++;
                    player.Character.Bank   -= price;
                    gasStation.MoneyStorage += price;
                    ownedVehicle.ActiveHandle.setSyncedData("fuel", ownedVehicle.Fuel);
                    client.setSyncedData("currentfuel", ownedVehicle.Fuel);
                }
                else
                {
                    StopRefill(client);
                }
            });

            client.setData("refuelTimer", timer);
        }