Exemple #1
0
        public bool FindCustomer(string i_LicencsePlate, out CustomerCard res)
        {
            bool isExist = false;

            res = null;
            if (r_ConnectedToDB == false)
            {
                isExist = r_CostumerBook.TryGetValue(i_LicencsePlate, out res);
            }
            else
            {
                FilterDefinition <BsonDocument> DBFilter = Builders <BsonDocument> .Filter.Eq("_id", i_LicencsePlate);

                BsonDocument vehicleBsonDocument = r_DBCollection.Find <BsonDocument>(DBFilter).FirstOrDefault();
                if (vehicleBsonDocument != null)
                {
                    res     = BsonSerializer.Deserialize <CustomerCard>(vehicleBsonDocument);
                    isExist = true;
                }
                else
                {
                    isExist = false;
                }
            }

            return(isExist);
        }
        public void EnterVehicle(Vehicle i_Vehicle, string i_Name, string i_Phone)
        {
            CustomerCard cutomerToAdd = new CustomerCard(i_Vehicle, i_Name, i_Phone);
            string       key          = cutomerToAdd.Vehicle.LicesncePlate;

            m_CostumerBook.Add(key, cutomerToAdd);
        }
Exemple #3
0
 public void RechargeVehicle(CustomerCard i_Cutomer, float i_Amount)
 {
     i_Cutomer.Vehicle.EnergySource.Load(i_Amount / 60);
     i_Cutomer.Vehicle.UpdateEnergyPercentageLeft();
     if (r_ConnectedToDB == true)
     {
         addEnergyDBactions(i_Cutomer);
     }
 }
Exemple #4
0
        public void BlowVehicleWheels(CustomerCard i_Customer)
        {
            i_Customer.Vehicle.BlowWheelsToMax();
            if (r_ConnectedToDB == true)
            {
                UpdateDefinition <BsonDocument> updateToDo = Builders <BsonDocument> .Update.Set("Vehicle.Wheels", i_Customer.Vehicle.Wheels);

                UpdateCustomerInDB(i_Customer.Vehicle.LicesncePlate, updateToDo);
            }
        }
Exemple #5
0
        public void ChangeCustomerVehicleState(CustomerCard i_Customer, eVehicleState i_VehicleState)
        {
            i_Customer.VehicleState = i_VehicleState;
            if (r_ConnectedToDB == true)
            {
                UpdateDefinition <BsonDocument> updateToDo = Builders <BsonDocument> .Update.Set("VehicleState", i_VehicleState.ToString());

                UpdateCustomerInDB(i_Customer.Vehicle.LicesncePlate, updateToDo);
            }
        }
        public void RefuelVehicle(CustomerCard i_Cutomer, float i_Amount, string i_TypeStr)
        {
            eFuelType        eType      = FromStringToVehicleFuelTypeEnum(i_TypeStr);
            FuelEnergySource fuelSource = i_Cutomer.Vehicle.EnergySource as FuelEnergySource;

            if (fuelSource.FuelType == eType)
            {
                fuelSource.Load(i_Amount);
            }
            else
            {
                throw new ArgumentException("Fuel type is not suitable to this vehicle");
            }
        }
Exemple #7
0
        public void EnterVehicle(Vehicle i_Vehicle, string i_Name, string i_Phone)
        {
            CustomerCard cutomerToAdd = new CustomerCard(i_Vehicle, i_Name, i_Phone);
            string       key          = cutomerToAdd.Vehicle.LicesncePlate;

            if (r_ConnectedToDB == true)
            {
                r_DBCollection.InsertOne(cutomerToAdd.ToBsonDocument());
            }
            else
            {
                r_CostumerBook.Add(key, cutomerToAdd);
            }
        }
        public bool FindCustomer(string i_LicencsePlate, out CustomerCard res)
        {
            bool isExist = false;

            res = null;
            foreach (KeyValuePair <string, CustomerCard> currentCostumer in m_CostumerBook)
            {
                if (currentCostumer.Value.Vehicle.LicesncePlate == i_LicencsePlate)
                {
                    isExist = true;
                    res     = currentCostumer.Value;
                }
            }

            return(isExist);
        }
Exemple #9
0
        public void RefuelVehicle(CustomerCard i_Customer, float i_Amount, string i_TypeStr)
        {
            eFuelType fuelType;

            if (IsFuelType(i_TypeStr, out fuelType) == true)
            {
                FuelEnergySource fuelSource = i_Customer.Vehicle.EnergySource as FuelEnergySource;
                if (fuelSource.FuelType == fuelType)
                {
                    fuelSource.Load(i_Amount);
                    i_Customer.Vehicle.UpdateEnergyPercentageLeft();
                    if (r_ConnectedToDB == true)
                    {
                        addEnergyDBactions(i_Customer);
                    }
                }
                else
                {
                    throw new ArgumentException("Fuel type is not suitable to this vehicle");
                }
            }
        }
 public void AddVehicleToGarage(Vehicle i_VehicleToAdd, CustomerCard i_ContactInfo)
 {
     m_Vehicles.Add(i_VehicleToAdd.LicencsePlateNumber, i_VehicleToAdd);
     m_ContactInfoDictionary.Add(i_VehicleToAdd.LicencsePlateNumber, i_ContactInfo);
 }
        public void ChangeCustomerVehicleState(CustomerCard i_Cutomer, string i_StateToChangeTo)
        {
            eCarState state = FromStringToCarStateEnum(i_StateToChangeTo);

            i_Cutomer.CarState = state;
        }
 public void RechargeVehicle(CustomerCard i_Cutomer, float i_Amount)
 {
     i_Cutomer.Vehicle.EnergySource.Load(i_Amount / 60);
 }
 public bool IsElectricEngine(CustomerCard i_Customer)
 {
     return(i_Customer.Vehicle.EnergySource is ElectricEnergySource);
 }
 public bool IsFuelEngine(CustomerCard i_Customer)
 {
     return(i_Customer.Vehicle.EnergySource is FuelEnergySource);
 }
 public void BlowVehicleWheels(CustomerCard i_Customer)
 {
     i_Customer.Vehicle.BlowWheelsToMax();
 }
Exemple #16
0
        private void addEnergyDBactions(CustomerCard i_Customer)
        {
            UpdateDefinition <BsonDocument> updateToDo = Builders <BsonDocument> .Update.Set("Vehicle.EnergySource.AmountOfEnergyLeft", i_Customer.Vehicle.EnergySource.CurrAmount).Set("Vehicle.PercentageOfEnergy", i_Customer.Vehicle.EnergyPercent);

            UpdateCustomerInDB(i_Customer.Vehicle.LicesncePlate, updateToDo);
        }