Example #1
0
 public SportCar CreateNewSportCar(double fuelTankVolume, double weight, int horsePower,
     EngineTypes engineType, string name, string param, Pilot pilot)
 {
     var sportCar = new SportCar(name, null, weight, param, pilot, fuelTankVolume,
         CreateGasolineEngine(horsePower, engineType));
     OnCarCreation(sportCar);
     return sportCar;
 }
Example #2
0
 public PilotUpdateDto(Pilot pilot)
 {
     if (pilot == null) return;
     Id = pilot.Id;
     Name = pilot.Name;
     Debutdate = pilot.DebutDate.ToString();
     Age = pilot.Age;
     Team = pilot.Team;
 }
Example #3
0
 public PilotModel(Pilot pilot)
 {
     Id = pilot.Id;
     Name = pilot.Name;
     Age = pilot.Age;
     Team = pilot.Team;
     DebutDate = pilot.DebutDate;
     ExperienceTime = Convert.ToInt32((DateTime.Now - DebutDate).TotalDays);
     CarCount = pilot.CarVehicles.Count;
 }
Example #4
0
 public Car(string name, double? mileage, double weight, string additionalInfo,
     Pilot pilot, double fuelTank, GasolineEngine engine)
     : base(name, mileage, weight, additionalInfo, pilot)
 {
     if (fuelTank < 0) throw new ArgumentException("fuel tank volume can't be below or equal zero");
     FuelTank = fuelTank;
     Engine = engine;
     FuelType = new Petrol();
     AccelerationSpeed = GetAccelerationSpeed();
 }
Example #5
0
 public ElectroCar(string name, double? mileage, ElectroEngine electroEngine, double weight,
     string additionalInfo,
     Pilot pilot, int chargeLevel)
     : base(name, mileage, weight, additionalInfo, pilot)
 {
     if (chargeLevel < 0 || chargeLevel > 100)
         throw new ArgumentException("Charge lvl can't be below zero or more than 100");
     ChargeLevel = chargeLevel;
     Engine = electroEngine;
     AccelerationSpeed = Engine.HorsePowers/Weight*100;
 }
Example #6
0
 public Vehicle(string name, double? mileage, double weight, string additionalInfo,
     Pilot pilot)
 {
     if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("please name the Vehicle!");
     if (weight <= 0) throw new ArgumentException("weight can't be below or equal zero");
     if (additionalInfo == null) additionalInfo = "No additional specs";
     Name = name;
     Mileage = mileage;
     Weight = weight;
     AdditionalInfo = additionalInfo;
     OwnerPilot = pilot;
 }
Example #7
0
        public void AddCar(Pilot pilot, Car car)
        {
            using (var tran = _session.BeginTransaction())
            {
                try
                {
                    pilot = _session.Load<Pilot>(pilot.Id);

                    pilot.AddCar(car);
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                    Logger.AddMsgToLog(ex.Message + "\n" + ex.StackTrace);
                    tran.Rollback();
                }
            }
        }
Example #8
0
 public void AddPilot(Pilot pilot)
 {
     using (var tran = _session.BeginTransaction())
     {
         try
         {
             Console.WriteLine("trying to add pilot in Database...");
             _session.Save(pilot);
             tran.Commit();
             Console.WriteLine("Succesfully!");
             Logger.AddMsgToLog("Succesfully! commited a pilot in database");
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
             Logger.AddMsgToLog(ex.Message + "\n" + ex.StackTrace);
             tran.Rollback();
         }
     }
 }
Example #9
0
 public void UpdatePilot(Pilot oldPilot, PilotUpdateDto pilotUpdateDto)
 {
     using (var tran = _session.BeginTransaction())
     {
         oldPilot.PilotEdit(pilotUpdateDto);
         tran.Commit();
     }
 }
Example #10
0
 public SportCar(string name, double? mileage, double weight, string additionalInfo,
     Pilot pilot, double fuelTank, GasolineEngine engine)
     : base(name, mileage, weight, additionalInfo, pilot, fuelTank, engine)
 {
     DownForcePressure = 0;
 }
Example #11
0
 public BoxesProxy(Pilot pilot, Boxes boxes)
 {
     _realBoxes = boxes;
     _realPilot = pilot;
 }
Example #12
0
 public ElectroCar CreateNewElectroCar(string name, double weight, int hpValue, Pilot pilot)
 {
     var electro = new ElectroCar(name, null, CreateElectroEngine(hpValue), weight, null, pilot, 0);
     ChargeCar(electro);
     return electro;
 }
Example #13
0
        public static Pilot CreateNewPilot(string name, string debutDateTime, int age, string teamName)
        {
            var pilot = new Pilot(name, debutDateTime, age, teamName);

            return pilot;
        }
Example #14
0
        public virtual Pilot PilotEdit(Pilot oldPilot, Pilot newPilot)
        {
            var editedPilot = oldPilot;
            editedPilot.Name = newPilot.Name;
            editedPilot.Age = newPilot.Age;
            editedPilot.DebutDate = newPilot.DebutDate;

            return editedPilot;
        }