Ejemplo n.º 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);
        }
Ejemplo n.º 2
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;

            m_CostumerBook.Add(key, cutomerToAdd);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 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");
                }
            }
        }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
        public void ChangeCustomerVehicleState(CustomerCard i_Cutomer, string i_StateToChangeTo)
        {
            eCarState state = FromStringToCarStateEnum(i_StateToChangeTo);

            i_Cutomer.CarState = state;
        }
Ejemplo n.º 12
0
 public void RechargeVehicle(CustomerCard i_Cutomer, float i_Amount)
 {
     i_Cutomer.Vehicle.EnergySource.Load(i_Amount / 60);
 }
Ejemplo n.º 13
0
 public bool IsElectricEngine(CustomerCard i_Customer)
 {
     return(i_Customer.Vehicle.EnergySource is ElectricEnergySource);
 }
Ejemplo n.º 14
0
 public bool IsFuelEngine(CustomerCard i_Customer)
 {
     return(i_Customer.Vehicle.EnergySource is FuelEnergySource);
 }
Ejemplo n.º 15
0
 public void BlowVehicleWheels(CustomerCard i_Customer)
 {
     i_Customer.Vehicle.BlowWheelsToMax();
 }
Ejemplo n.º 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);
        }