private double GetTravelDurationOnOrbit(IWeather weather, VehicleTypeEnum vehicleTypeEnum) { double CraterCountForInputWeather = weather.GetModifiedCratersCountBasedOnWeather(NoOfCraters); double timeToCrossCrater; double timeToCrossOrbit; switch (vehicleTypeEnum) { case VehicleTypeEnum.BIKE: Bike objbike = ObjectFactory.GetBikeInstance; timeToCrossCrater = (objbike.TimeToCrossCrater * CraterCountForInputWeather); timeToCrossOrbit = ((_distance / (_speed > objbike.Speed ? objbike.Speed : _speed)) * 60); break; case VehicleTypeEnum.CAR: Car objcar = ObjectFactory.GetCarInstance; timeToCrossCrater = (objcar.TimeToCrossCrater * CraterCountForInputWeather); timeToCrossOrbit = ((_distance / (_speed > objcar.Speed ? objcar.Speed : _speed)) * 60); break; case VehicleTypeEnum.TUKTUK: Tuktuk objtuktuk = ObjectFactory.GetTuktukInstance; timeToCrossCrater = (objtuktuk.TimeToCrossCrater * CraterCountForInputWeather); timeToCrossOrbit = ((_distance / (_speed > objtuktuk.Speed ? objtuktuk.Speed : _speed)) * 60); break; default: throw new InvalidOperationException("Invalid Vehicle Type"); } return(timeToCrossCrater + timeToCrossOrbit); }
public bool HasPicoPlaca(VehicleTypeEnum vehicleTypeId, int day, int vehicleLastNumberId) { var result = _repository.List(repo => repo.Type == vehicleTypeId).FirstOrDefault(); var picoPlacaResult = _picoPlacarepository.List(repo => repo.PlacaEntityID == result.Id && repo.Day == day && repo.Digit == vehicleLastNumberId); return(picoPlacaResult?.Count() > 0); }
public Car() { _name = "CAR"; _speed = 20; _timeToCrossCrater = 3; _vehicleType = VehicleTypeEnum.CAR; }
public Bike() { _name = "BIKE"; _speed = 10; _timeToCrossCrater = 2; _vehicleType = VehicleTypeEnum.BIKE; }
public Tuktuk() { _name = "TUKTUK"; _speed = 12; _timeToCrossCrater = 1; _vehicleType = VehicleTypeEnum.TUKTUK; }
public void GetLastNumber_WithBadLength_ShouldReturnException() { // Arrange (preparación, organizar) var PlacaService = new PlacaService(_placaRepository.Object, _picoPlacarepository.Object); VehicleTypeEnum vehicleType = VehicleTypeEnum.motorcycle; string vehicleId = "SFL55"; var placaEntity = new PlacaBuilder() .WithLastNumberFrom(2) .Build(); var listRepository = new List <PlacaEntity>(); listRepository.Add(placaEntity); _placaRepository.Setup(pr => pr.List(r => r.Type == VehicleTypeEnum.motorcycle)).Returns(listRepository); // Act try { PlacaService.GetLastNumberOfIdVehicle(vehicleType, vehicleId); } catch (Exception e) { var message = "La placa del vehículo posee un problema en el formato. La longitud debe ser de 6"; // Assert (confirmacion) Assert.IsInstanceOfType(e, typeof(PlacaException)); Assert.AreEqual(e.Message, message); } }
public VehicleType(int vehicleTypeId, string vehicleTypeLongName, string vehicleTypeShortName, string vehicleTypeEnumName) { VehicleTypeId = vehicleTypeId; VehicleTypeLongName = vehicleTypeLongName; VehicleTypeShortName = vehicleTypeShortName; VehicleTypeEnumName = vehicleTypeEnumName; VehicleEnum = (VehicleTypeEnum)VehicleTypeId; }
public CrewSlotConfiguration(int crewId, Nation crewNation, string vehicleName, int trainedMembers, VehicleTypeEnum vehicleType, VehicleCategoryEnum vehicleCategory) { CrewId = crewId; CrewNation = crewNation; VehicleName = vehicleName; TrainedMembers = trainedMembers; VehicleType = vehicleType; VehicleCategory = vehicleCategory; }
public Leg(LegDto leg) { DepartureTime = leg.DepartureTime; ArrivalTime = leg.ArrivalTime; Duration = TimeSpan.FromTicks(leg.Duration); SummaryHtml = leg.SummaryHtml; Stops = leg.ScheduledStopCalls?.Count ?? 0; Polyline = leg.Polyline; VehicleType = leg.VehicleType; }
public CellEntity DecreaseCell(VehicleTypeEnum vehicleType, int decrease) { var cellEntity = _cellRepository.List(cell => cell.IdVehicleType == vehicleType).FirstOrDefault(); cellEntity.NumCellAvaliable -= decrease; if (cellEntity.NumCellAvaliable < 0) { throw new CellException("No hay más celdas disponibles"); } _cellRepository.Update(cellEntity); return(cellEntity); }
public IVehicle Build(VehicleTypeEnum type) { switch (type) { case VehicleTypeEnum.Car: return(new Car()); case VehicleTypeEnum.MotorHome: return(new MotorHome()); default: throw new NotImplementedException($"{type} not implemented"); } }
private Vehicle CreateNewVehicle(string name, int id, int numberOfWheels, VehicleTypeEnum vehicleType) { Vehicle vec = new Vehicle() { Id = id, ChasisNumber = Util.RandomString(), ModelNumber = Util.RandomNum(1000, 9999).ToString(), NumberOfWheels = numberOfWheels, VehicleType = vehicleType.ToString(), Name = string.Format("{0}_{1}", name, Util.RandomString(6)), RegistrationNumber = Util.RandomString() }; return vec; }
public static Tuple <VehicleTypeEnum, double> GetMinKeyValueFromDictionary(Dictionary <VehicleTypeEnum, double> keyValuePairs) { double value = double.MaxValue; VehicleTypeEnum retval = VehicleTypeEnum.NONE; foreach (KeyValuePair <VehicleTypeEnum, double> keyValuePair in keyValuePairs) { if (keyValuePair.Value < value) { value = keyValuePair.Value; retval = keyValuePair.Key; } } return(new Tuple <VehicleTypeEnum, double>(retval, value)); }
private Vehicle CreateNewVehicle(string name, int id, int numberOfWheels, VehicleTypeEnum vehicleType) { Vehicle vec = new Vehicle() { Id = id, ChasisNumber = Util.RandomString(), ModelNumber = Util.RandomNum(1000, 9999).ToString(), NumberOfWheels = numberOfWheels, VehicleType = vehicleType.ToString(), Name = string.Format("{0}_{1}", name, Util.RandomString(6)), RegistrationNumber = Util.RandomString() }; return(vec); }
public CellEntity IncreaseCell(VehicleTypeEnum vehicleType, int increase) { var cellEntity = _cellRepository.List(cell => cell.IdVehicleType == vehicleType).FirstOrDefault(); if (cellEntity.NumCellAvaliable < cellEntity.NumTotalCells) { cellEntity.NumCellAvaliable += increase; } else { throw new CellException("No hay más celdas disponibles"); } _cellRepository.Update(cellEntity); return(cellEntity); }
/// <summary> /// Gets the size of the tax rate for additional displacement. /// </summary> /// <param name="displacement">The displacement.</param> /// <param name="vehicleTypeEnum">The vehicle type enum.</param> /// <returns></returns> private decimal GetTaxRateForAdditionalDisplacementSize(int displacement, VehicleTypeEnum vehicleTypeEnum) { decimal taxRate = 0; if (vehicleTypeEnum == VehicleTypeEnum.Car) { if (displacement <= 2499) { taxRate = 0; } else if (displacement >= 2500 && displacement <= 2999) { taxRate = 8; } else if (displacement >= 3000 && displacement <= 3499) { taxRate = 10; } else if (displacement >= 3500 && displacement <= 3999) { taxRate = 13; } else if (displacement >= 4000) { taxRate = 16; } } else if (vehicleTypeEnum == VehicleTypeEnum.BikeWithEngine || vehicleTypeEnum == VehicleTypeEnum.Motorbike) { if (displacement <= 999) { taxRate = 0; } else if (displacement >= 1000) { taxRate = 5; } } return(taxRate); }
public string GetLastNumberOfIdVehicle(VehicleTypeEnum vehicleTypeId, string vehicleId) { string lastNumber = string.Empty; if (vehicleTypeId == VehicleTypeEnum.car) { lastNumber = vehicleId.Last().ToString(); } if (vehicleTypeId == VehicleTypeEnum.motorcycle) { var placa = _repository.List(r => r.Type == VehicleTypeEnum.motorcycle).FirstOrDefault(); if (vehicleId.Length < placa.Length) { throw new PlacaException($"La placa del vehículo posee un problema en el formato. La longitud debe ser de {placa.Length}"); } lastNumber = vehicleId.TakeLast(placa.LastNumberFrom).FirstOrDefault().ToString(); } return(lastNumber); }
public bool Validation(MaintenanceTypeEnum maintenanceType, VehicleTypeEnum vehicleType) { try { var vehicleTypes = _invalidServices[maintenanceType]; if (vehicleTypes == null) { return(true); } return(vehicleTypes.All(v => v != vehicleType)); } catch (KeyNotFoundException ex) { Console.WriteLine(ex.Message); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(true); } }
public EntryDTOBuilder WithVehicleType(VehicleTypeEnum vehicleId) { IdVehicleType = vehicleId; return(this); }
public RateEntity GetRateByVehicleType(VehicleTypeEnum vehicleType) { return(_rateRepository.List(rr => rr.IdVehicleType == vehicleType).FirstOrDefault()); }
public bool ExistsQuotaByVehicleType(VehicleTypeEnum vehicleType) { var cell = _cellRepository.List(c => c.IdVehicleType == vehicleType).FirstOrDefault(); return(cell?.NumCellAvaliable > 0); }
public Vehicle(VehicleTypeEnum vehicleTypes, string licensePlate, DateTime parkingTime) { this.vehicleTypes = vehicleTypes; this.licensePlate = licensePlate; this.parkingTime = parkingTime; }
/// <summary> /// Gets the tax rate for the given co2 exhaust. /// </summary> /// <param name="co2Exhaust">The co2 exhaust.</param> /// <param name="powerKw"></param> /// <param name="fuelTypeEnum">The fuel type enum.</param> /// <param name="vehicleTypeEnum"></param> /// <param name="atLeastEightSeatsVehicle"></param> /// <returns></returns> /// <exception cref="System.Exception">Not known FuelTypeEnum. + fuelTypeEnum</exception> private decimal GetTaxRateForTheGivenCo2Exhaust(int co2Exhaust, int powerKw, FuelTypeEnum fuelTypeEnum, VehicleTypeEnum vehicleTypeEnum, bool atLeastEightSeatsVehicle, EuroExhaustTypeEnum euroExhaustTypeEnum) { decimal taxRate = 0; if (vehicleTypeEnum == VehicleTypeEnum.Car) { //Za motorna vozila iz četrtega odstavka tega člena s pogonom na dizelsko gorivo s stopnjo izpusta Euro 6 se upošteva stopnja davka iz lestvice v četrtem odstavku tega člena za bencinsko gorivo. if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro6 && fuelTypeEnum == FuelTypeEnum.Diesel) { fuelTypeEnum = FuelTypeEnum.PetrolRest; } if (fuelTypeEnum == FuelTypeEnum.PetrolRest || fuelTypeEnum == FuelTypeEnum.Electric) { if (co2Exhaust > 0 && co2Exhaust <= 110) { taxRate = 0.5m; } else if (co2Exhaust > 110 && co2Exhaust <= 120) { taxRate = 1; } else if (co2Exhaust > 120 && co2Exhaust <= 130) { taxRate = 1.5m; } else if (co2Exhaust > 130 && co2Exhaust <= 150) { taxRate = 3; } else if (co2Exhaust > 150 && co2Exhaust <= 170) { taxRate = 6; } else if (co2Exhaust > 170 && co2Exhaust <= 190) { taxRate = 9; } else if (co2Exhaust > 190 && co2Exhaust <= 210) { taxRate = 13; } else if (co2Exhaust > 210 && co2Exhaust <= 230) { taxRate = 18; } else if (co2Exhaust > 230 && co2Exhaust <= 250) { taxRate = 23; } else if (co2Exhaust == 0 || co2Exhaust > 250) { taxRate = 28; } } else if (fuelTypeEnum == FuelTypeEnum.Diesel) { if (co2Exhaust > 0 && co2Exhaust <= 110) { taxRate = 1; } else if (co2Exhaust > 110 && co2Exhaust <= 120) { taxRate = 2; } else if (co2Exhaust > 120 && co2Exhaust <= 130) { taxRate = 3; } else if (co2Exhaust > 130 && co2Exhaust <= 150) { taxRate = 6; } else if (co2Exhaust > 150 && co2Exhaust <= 170) { taxRate = 11; } else if (co2Exhaust > 170 && co2Exhaust <= 190) { taxRate = 15; } else if (co2Exhaust > 190 && co2Exhaust <= 210) { taxRate = 18; } else if (co2Exhaust > 210 && co2Exhaust <= 230) { taxRate = 22; } else if (co2Exhaust > 230 && co2Exhaust <= 250) { taxRate = 26; } else if (co2Exhaust == 0 || co2Exhaust > 250) { taxRate = 31; } } else { throw new Exception("Not known FuelTypeEnum. " + fuelTypeEnum); } //Za motorna vozila iz četrtega odstavka tega člena z najmanj osmimi sedeži se stopnja davka iz četrtega odstavka tega člena zniža za 30%. if (atLeastEightSeatsVehicle) { taxRate = taxRate - (taxRate * 0.30m); } } else if (vehicleTypeEnum == VehicleTypeEnum.BikeWithEngine || vehicleTypeEnum == VehicleTypeEnum.Motorbike) { if (powerKw > 0 && powerKw <= 25) { taxRate = 1.5m; } else if (powerKw > 25 && powerKw <= 50) { taxRate = 2; } else if (powerKw > 50 && powerKw <= 75) { taxRate = 3; } else if (powerKw > 75) { taxRate = 5; } if (fuelTypeEnum == FuelTypeEnum.Electric) { taxRate = 0.5m; } } else if (vehicleTypeEnum == VehicleTypeEnum.LivingVan) { if (powerKw > 0 && powerKw <= 60) { taxRate = 6; } else if (powerKw > 60 && powerKw <= 90) { taxRate = 9; } else if (powerKw > 90 && powerKw <= 120) { taxRate = 13; } else if (powerKw > 120) { taxRate = 18; } if (fuelTypeEnum == FuelTypeEnum.Electric) { taxRate = 0.5m; } } else { throw new Exception("Not known VehicleTypeEnum. " + vehicleTypeEnum); } return(taxRate); }
/// <summary> /// Gets the special tax rate additionally. /// </summary> /// <param name="dieselParticlesAbove005Limit">if set to <c>true</c> [diesel particles above005 limit].</param> /// <param name="fuelTypeEnum">The fuel type enum.</param> /// <param name="vehicleTypeEnum">The vehicle type enum.</param> /// <param name="engineTypeEnum">The engine type enum.</param> /// <returns></returns> private decimal GetSpecialTaxRateAdditionally(bool dieselParticlesAbove005Limit, FuelTypeEnum fuelTypeEnum, VehicleTypeEnum vehicleTypeEnum, EngineTypeEnum engineTypeEnum) { decimal taxRate = 0; if (vehicleTypeEnum == VehicleTypeEnum.Car) { //Za motorna vozila iz četrtega odstavka tega člena s pogonom na dizelsko gorivo z izpustom trdnih delcev, večjim od 0,005 g/km, se stopnja davka, določena v četrtem odstavku tega člena, poveča za dve odstotni točki, po 1. januarju 2011 pa za pet odstotnih točk. if (fuelTypeEnum == FuelTypeEnum.Diesel && dieselParticlesAbove005Limit) { taxRate += 5; } } else if (vehicleTypeEnum == VehicleTypeEnum.BikeWithEngine || vehicleTypeEnum == VehicleTypeEnum.Motorbike) { //Za motorna vozila iz prejšnjega odstavka z dvotaktnim motorjem na notranje zgorevanje, se stopnja davka, določena v prejšnjem odstavku, poveča za tri odstotne točke. if (engineTypeEnum == EngineTypeEnum.TwoTacts) { taxRate += 3; } } else if (vehicleTypeEnum == VehicleTypeEnum.LivingVan) { //Za motorna vozila iz osemnajstega odstavka tega člena s pogonom na dizelsko gorivo z izpustom trdnih delcev, večjim od 0,005 g/km, se stopnja davka, določena v osemnajstem odstavku tega člena, poveča za dve odstotni točki, po 1. januarju 2011 pa za pet odstotnih točk. if (fuelTypeEnum == FuelTypeEnum.Diesel && dieselParticlesAbove005Limit) { taxRate += 5; } } return(taxRate); }
public CellEntityBuilder WithVehicleType(VehicleTypeEnum vehicleTypeEnum) { IdVehicleType = vehicleTypeEnum; return(this); }
/// <summary> /// Gets the additional tax rate basedon euro exhaust. /// </summary> /// <param name="euroExhaustTypeEnum">The euro exhaust type enum.</param> /// <param name="vehicleTypeEnum">The vehicle type enum.</param> /// <param name="dieselParticlesAbove005Limit">if set to <c>true</c> [diesel particles above005 limit].</param> /// <returns></returns> /// <exception cref="System.Exception"> /// Not known EuroExhaustTypeEnum. + euroExhaustTypeEnum /// or /// Not known VehicleTypeEnum. + vehicleTypeEnum /// </exception> private decimal GetAdditionalTaxRateBasedonEuroExhaust(EuroExhaustTypeEnum euroExhaustTypeEnum, VehicleTypeEnum vehicleTypeEnum) { decimal taxRate = 0; if (vehicleTypeEnum == VehicleTypeEnum.Car) { if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro1 || euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro2) { taxRate = 10; } else if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro3) { taxRate = 5; } else if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro4) { taxRate = 2; } } else if (vehicleTypeEnum == VehicleTypeEnum.BikeWithEngine || vehicleTypeEnum == VehicleTypeEnum.Motorbike) { if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro1) { taxRate = 10; } else if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro2 && vehicleTypeEnum != VehicleTypeEnum.BikeWithEngine) { taxRate = 5; } } else if (vehicleTypeEnum == VehicleTypeEnum.LivingVan) { if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro1 || euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro2) { taxRate = 10; } else if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro3) { taxRate = 5; } else if (euroExhaustTypeEnum == EuroExhaustTypeEnum.Euro4) { taxRate = 2; } } else { throw new Exception("Not known VehicleTypeEnum. " + vehicleTypeEnum); } return(taxRate); }
public PlacaBuilder WithType(VehicleTypeEnum type) { Type = type; return(this); }
public static VehicleType GetVehicleTypeDetailsFromEnum(VehicleTypeEnum vehicleType) { return LoadVehicleTypesDataFromJson(Resources.vehicle_types_json).ToList().Single(v => v.VehicleEnum == vehicleType); }