Esempio n. 1
0
 public Vehicle(string registrationNumber, VehicleModel model, string color, long currentKM = 0)
 {
     _registrationNumber = registrationNumber;
     _model = model;
     _color = color;
     _currentKM = currentKM;
 }
Esempio n. 2
0
        protected virtual void OnFormTransactionSuccess(VehicleModel model, bool status)
        {
            EventHandler<FormTransactionSuccessArgs<VehicleModel>> handler = FormTransactionSuccess;

            if (handler != null)
            {
                handler(this, new FormTransactionSuccessArgs<VehicleModel>(model, true));
            }
        }
        private int _modelYear; // Lookup based on ModelYearCode

        #endregion Fields

        #region Constructors

        internal VehicleIdentificationNumber(string vinNumber, IVinNumberDecoder decoder)
        {
            _vinNumber = vinNumber;
            _decoder = decoder;

            _maker = _decoder.DecodeAutoMaker(_vinNumber);
            _model = _decoder.DecodeVechicleModel(_vinNumber);
            _isAmericanBuilt = _decoder.IsAmericanMade(_vinNumber);
            _modelYear = _decoder.DecodeModelYear(_vinNumber);
            _isValid = Validate(_vinNumber);
        }
Esempio n. 4
0
        public void Insert(ModelsItem model)
        {
            VehicleModel newModel = new VehicleModel()
            {
                VehicleMakeId    = model.VehicleMakeId,
                VehicleModelName = model.VehicleModelName,
                UserId           = model.UserId,
                CreatedDate      = DateTime.Now
            };

            var lastId   = _vehicleModels.MaxBy(x => x.VehicleModelId).FirstOrDefault();
            int newId    = lastId.VehicleModelId + 1;
            var makeRepo = new VehicleMakeRepoQA();

            model.VehicleMakeName = makeRepo.GetById(model.VehicleMakeId).VehicleMakeName;

            newModel.VehicleModelId = newId;
            model.VehicleModelId    = newId;
            model.CreatedDate       = DateTime.Now;

            _vehicleModels.Add(newModel);
            _modelsItems.Add(model);
        }
Esempio n. 5
0
        // Add new

        public async Task <bool> AddNew(VehicleModel vehicleModel)
        {
            try
            {
                vehicleModel.Status        = "Vehicle IN";
                vehicleModel.VehicleInDate = DateTime.Now;
                _dbContext.VehicleModels.Add(vehicleModel);
                int i = await _dbContext.SaveChangesAsync();

                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
        public void Test_LiteDB_SeedDB()
        {
            //Load sample records
            var v1 = new VehicleModel();

            v1.Type      = "car";
            v1.Name      = "Honda Civic";
            v1.FuelLevel = 50;
            v1.Mileage   = 120;
            _liteDB.CreateRecord(v1);

            var car2 = new VehicleModel();

            car2.Type      = "car";
            car2.Name      = "Moza 3";
            car2.FuelLevel = 80;
            car2.Mileage   = 240;
            _liteDB.CreateRecord(car2);

            int count = _liteDB.RecordCount();

            Assert.IsTrue(count > 1);
        }
Esempio n. 7
0
        public VehicleModelViewModel Edit(VehicleModelViewModel modelVM)
        {
            if (modelVM.Id == null)
            {
                throw new ArgumentNullException("Id is null");
            }

            VehicleModel model = _db.VehicleModel.Where(m => m.Id == modelVM.Id).FirstOrDefault();

            if (model == null)
            {
                throw new ArgumentNullException("Model is null");
            }

            model.Name    = modelVM.Name;
            model.Abrv    = modelVM.Abrv;
            model.Make_Id = modelVM.Make_Id;

            _db.VehicleModel.AddOrUpdate(model);
            _db.SaveChanges();

            return(Mapper.Map(model, modelVM));
        }
Esempio n. 8
0
        public static void Test_RetrieveChar()
        {
            var uid       = AccountModel.CreateAccount(DbConnection.Connection, "127.0.0.1", "admin", "admin");
            var character = new Character
            {
                Uid    = (ulong)uid,
                Name   = "GigaToni",
                Avatar = 1,
            };

            CharacterModel.CreateCharacter(DbConnection.Connection, ref character);
            character.ActiveVehicleId = (uint)VehicleModel.Create(DbConnection.Connection, new Vehicle()
            {
                CarType = 1,
                Color   = 0,
            }, character.Id);
            CharacterModel.Update(DbConnection.Connection, character);

            character = null;
            character = CharacterModel.Retrieve(DbConnection.Connection, "GigaToni");
            Assert.IsNotNull(character);
            Console.WriteLine(character.Name);
        }
 public IActionResult UpdateVehicle([FromBody] VehicleModel model)
 {
     try {
         if (model == null)
         {
             return(BadRequest("Body content is not valid!"));
         }
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var entity = model.Map <VehicleEntity>();
         entity.ManufactureDate = entity.ManufactureDate.ToLocalTime();
         entity = _vehicleLogic.UpdateVehicle(entity);
         if (entity == null)
         {
             return(BadRequest("Somthing went wrong while updating model in DB!"));
         }
         return(Ok(entity));
     } catch (Exception e) {
         return(StatusCode(500, e));
     }
 }
Esempio n. 10
0
        public ActionResult AddVehicle(VehicleModel vehicleModel)
        {
            try
            {
                if (Session["User"] == null) return RedirectToAction("Login", "Account");
                if (vehicleModel != null)
                {
                    var user = (UserModel)Session["User"];
                     var enterprice = vehicleModel.CustumerType != (int)Enums.Enterprice.Bireysel;
                    var model = new VehicleModel
                    {
                        CreatedById = user.UserId,
                        CreatedDate = DateTime.Now,
                        Enterprice = enterprice,
                        Description = vehicleModel.Description,
                        IsDeleted = false,
                        Model = vehicleModel.Model,
                        VehicleName = vehicleModel.VehicleName,
                        VehiclePlate = vehicleModel.VehiclePlate,
                        VehicleType = vehicleModel.VehicleType
            
                    };
                    var add = _vehicleRepository.AddNewVehicleByVehicleModel(model);
                    if (add!=null)
                    {
                        return RedirectToAction("VehicleList", "Vehicle");
                    }
                }
                return View();
            }
            catch (Exception)
            {

                throw;
            }

        }
Esempio n. 11
0
        private bool SpawnPurchasedVehicle(Client player, List <Vector3> spawns, VehicleHash vehicleHash, int vehiclePrice, string firstColor, string secondColor)
        {
            for (int i = 0; i < spawns.Count; i++)
            {
                // Check if the spawn point has a vehicle on it
                bool spawnOccupied = NAPI.Pools.GetAllVehicles().Where(veh => spawns[i].DistanceTo(veh.Position) < 2.5f).Any();

                if (!spawnOccupied)
                {
                    // Basic data for vehicle creation
                    VehicleModel vehicleModel = new VehicleModel();
                    vehicleModel.model       = GetVehicleModel(vehicleHash);
                    vehicleModel.plate       = string.Empty;
                    vehicleModel.position    = spawns[i];
                    vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                    vehicleModel.owner       = player.GetData(EntityData.PLAYER_NAME);
                    vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                    vehicleModel.firstColor  = firstColor;
                    vehicleModel.secondColor = secondColor;
                    vehicleModel.pearlescent = 0;
                    vehicleModel.price       = vehiclePrice;
                    vehicleModel.parking     = 0;
                    vehicleModel.parked      = 0;
                    vehicleModel.engine      = 0;
                    vehicleModel.locked      = 0;
                    vehicleModel.gas         = 50.0f;
                    vehicleModel.kms         = 0.0f;

                    // Creating the purchased vehicle
                    Vehicles.CreateVehicle(player, vehicleModel, false);

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 12
0
        public void _202_AddVehicleWithDublicateVin()
        {
            vehiclePage.AddVehicleBtn.Click();
            addNewVehiclePage = new AddEditNewVehiclePage(_driver);
            Assert.IsTrue(addNewVehiclePage.IsDisplayed());

            vehicle = new VehicleModel();

            addNewVehiclePage.MakeInputField.SendKeys(vehicle.Make);
            addNewVehiclePage.ModelInputField.SendKeys(vehicle.Model);
            addNewVehiclePage.YearInputField.SendKeys(vehicle.Year);
            addNewVehiclePage.VinInputField.SendKeys(vehicle.Vin);
            addNewVehiclePage.DescriptionInputField.SendKeys(vehicle.Descriptopn);

            addNewVehiclePage.SaveBtn.Click();

            vehiclePage.AddVehicleBtn.Click();
            addNewVehiclePage = new AddEditNewVehiclePage(_driver);
            Assert.IsTrue(addNewVehiclePage.IsDisplayed());



            addNewVehiclePage.MakeInputField.SendKeys(vehicle.Make);
            addNewVehiclePage.ModelInputField.SendKeys(vehicle.Model);
            addNewVehiclePage.YearInputField.SendKeys(vehicle.Year);
            addNewVehiclePage.VinInputField.SendKeys(vehicle.Vin);
            addNewVehiclePage.DescriptionInputField.SendKeys(vehicle.Descriptopn);

            addNewVehiclePage.SaveBtn.Click();

            Assert.IsTrue(addNewVehiclePage.ElementIsShown(addNewVehiclePage.ValidatioinError));
            Assert.IsTrue(addNewVehiclePage.ElementIsShown(addNewVehiclePage.ValidatioinErrorMessage));
            Assert.AreEqual("The vehicle with the same VIN already exists.",
                            addNewVehiclePage.ValidatioinErrorMessage.Text);

            addNewVehiclePage.VehiclesTabLink.Click();
        }
Esempio n. 13
0
 private void btnupdatemodeldetails_Click(object sender, EventArgs e)
 {
     if (txtboxdetailmodel.Text.ToString() == "")
     {
         RadMessageBox.Show("Enter All Values");
         return;
     }
     else if (comboboxdetailmaker.SelectedValue == null)
     {
         RadMessageBox.Show("Please Choose Vehicle Category");
         return;
     }
     try
     {
         VehicleModel vehicleModel = new VehicleModel()
         {
             VehicelModelId   = Convert.ToInt32(txtboxcatid.Text.ToString()),
             Name             = txtboxdetailmodel.Text.ToString().ToUpper(),
             vehicle_maker_id = Convert.ToInt32(comboboxdetailmaker.SelectedValue.ToString())
         };
         if (new VehicleModelBusiness().UpdateVehicleModel(vehicleModel))
         {
             RadMessageBox.Show("updated");
             txtboxdetailmodel.Clear();
             btnupdatemodeldetails.Enabled = false;
             btndltmodeldetails.Enabled    = false;
             comboboxdataInitialize();
         }
         else
         {
             RadMessageBox.Show("Failed");
         }
     }
     catch (Exception exception)
     {
     }
 }
Esempio n. 14
0
        public List <VehicleModel> GetVehicleList()
        {
            List <VehicleModel> _Vehicle = new List <VehicleModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(DBConn))
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT * FROM Vehicles Order by AddedAt desc", conn))//call Stored Procedure
                    {
                        cmd.CommandType = System.Data.CommandType.Text;
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            VehicleModel _data = new VehicleModel()
                            {
                                ID = reader["ID"].ToString(),
                                VehicleRegistration = reader["VehicleRegistration"].ToString(),
                                VehicleType         = reader["VehicleType"].ToString(),
                                VehicleCapacity     = (int)reader["VehicleCapacity"],
                                FuelConsumption     = reader["FuelConsumption"].ToString(),
                                IsAvailable         = Convert.ToInt32(reader["IsAvailable"]),
                                AddedBy             = reader["AddedBy"].ToString(),
                            };
                            _Vehicle.Add(_data);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(_Vehicle);
        }
        /// <summary>
        ///  database connection for Registrion
        /// </summary>
        /// <param name="data"> store the Complete Parking information</param>
        /// <returns></returns>
        public async Task <bool> VehicleParking(VehicleModel data)
        {
            try
            {
                SqlConnection connection = DatabaseConnection();
                //for store procedure and connection to database
                SqlCommand command = StoreProcedureConnection("spVehicleParking", connection);
                command.Parameters.AddWithValue("@UserID", data.UserID);
                command.Parameters.AddWithValue("@VehicleOwnerAddress", data.VehicleOwnerAddress);
                command.Parameters.AddWithValue("@VehicleNumber", data.VehicleNumber);
                command.Parameters.AddWithValue("@VehicalBrand", data.VehicalBrand);
                command.Parameters.AddWithValue("@VehicalColor", data.VehicalColor);
                command.Parameters.AddWithValue("@ParkingSlot", data.ParkingSlot);
                command.Parameters.AddWithValue("@ParkingUserCategory", data.ParkingUserCategory);
                command.Parameters.AddWithValue("@ParkingStatus", data.ParkingStatus);
                command.Parameters.AddWithValue("@Charges", data.Charges);
                command.Parameters.AddWithValue("@EntryTime", data.EntryTime);
                command.Parameters.AddWithValue("@ExitTime", data.ExitTime);
                connection.Open();
                int Response = await command.ExecuteNonQueryAsync();

                connection.Close();
                if (Response != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 16
0
        public async Task <bool> AddVehicle(VehicleModel model)
        {
            try
            {
                var url  = _baseUrl;
                var data = JsonSerializer.Serialize(model);

                var response = await _http.PostAsync(url, new StringContent(data, Encoding.Default, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    var error = response.Content.ReadAsStringAsync().Result;
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private void FixedUpdate()
        {
            RaycastHit hitOn;
            RaycastHit hitNear;

            OnGround   = Physics.Raycast(transform.position, Vector3.down, out hitOn, rayMaxDistance);
            NearGround = Physics.Raycast(transform.position, Vector3.down, out hitNear, rayMaxDistance + 0.8f);

            VehicleModel.up = Vector3.Lerp(VehicleModel.up, hitNear.normal, Time.deltaTime * 8.0f);
            VehicleModel.Rotate(0, transform.eulerAngles.y, 0);

            if (NearGround)
            {
                PhysicsSphere.AddForce(transform.forward * speedTarget, ForceMode.Acceleration);
                PhysicsSphere.AddForce(transform.right * strafeTarget, ForceMode.Acceleration);
            }
            else
            {
                PhysicsSphere.AddForce(transform.forward * (speedTarget / 10), ForceMode.Acceleration);
                PhysicsSphere.AddForce(Vector3.down * Gravity, ForceMode.Acceleration);
            }

            Vector3 localVelocity = transform.InverseTransformVector(physicsSphere.velocity);

            localVelocity.x *= 0.9f + (Drift / 10);

            if (NearGround)
            {
                PhysicsSphere.velocity = transform.TransformVector(localVelocity);
            }

            if (StopSlopeSlide)
            {
                CounterSlopes(hitNear.normal);
            }
        }
Esempio n. 18
0
        private async Task EditionModeToggle()
        {
            if (_editionMode)
            {
                EditBtn.Text = "Editar";
                CleanForm();
            }
            else
            {
                EditBtn.Text = "Cancelar modificacion";

                _entityToEdit = await _VehicleModel.Get(GetIdCurrentRow());

                txtDescription.Text   = _entityToEdit.Description;
                cbType.SelectedValue  = _entityToEdit.VehicleTypeId;
                cbBrand.SelectedValue = _entityToEdit.VehicleBrandId;
                cbStatus.SelectedItem = _entityToEdit.Status;
            }

            DeleteBtn.Enabled     = !DeleteBtn.Enabled;
            dataGridView1.Enabled = !dataGridView1.Enabled;

            _editionMode = !_editionMode;
        }
Esempio n. 19
0
        public IActionResult UpdateVehicle(string vehicleNumber, VehicleModel vehicleModel)
        {
            try
            {
                if (vehicleModel == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                vehicleModel.vehicleNumber = vehicleNumber;
                VehicleModel updatedVehicle = vehicleRepository.UpdateVehicle(vehicleModel);
                return(Ok(updatedVehicle));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
Esempio n. 20
0
        public void WhenGettingList_ThenRemindersReturned()
        {
            var vehicle = new VehicleModel(new Vehicle {
                VehicleId = defaultVehicleId
            },
                                           new VehicleStatisticsModel());

            var reminders = new[]
            {
                new Reminder {
                    ReminderId = 1, Title = "test reminder"
                },
                new Reminder {
                    ReminderId = 2
                }
            };

            MockHandlerFor <GetAllRemindersForVehicle>(
                x => x
                .Setup(h => h.Execute(defaultVehicleId))
                .Returns(reminders));

            MockHandlerFor <GetVehicleById>(
                x => x
                .Setup(h => h.Execute(_defaultUser.UserId, defaultVehicleId))
                .Returns(vehicle));

            var controller = GetTestableReminderController();

            var result = (ContentTypeAwareResult)controller.List(defaultVehicleId);
            var data   = (List <ReminderListViewModel>)result.Model;

            Assert.NotNull(data);
            Assert.Equal(reminders.Count(), data.First().Reminders.Count());
            Assert.Equal("test reminder", data.First().Reminders.First().Title);
        }
Esempio n. 21
0
        public List <VehicleModel> GetVehicle()
        {
            var list = new List <VehicleModel>();

            foreach (var foundvehicle in DBContext.Vehicle)
            {
                var vehicle = new VehicleModel();
                vehicle.RegNr           = foundvehicle.RegNr;
                vehicle.Color_ID        = foundvehicle.Color_Id.Value;
                vehicle.Manufacturer_ID = foundvehicle.Manufact_Id;
                vehicle.Model_ID        = foundvehicle.Model_Id;
                vehicle.TripMeter       = foundvehicle.TripMeter;
                vehicle.YearModel       = foundvehicle.YearModel.Value;

                foreach (var report in DBContext.Report.Where(report => foundvehicle.RegNr == report.Vehicle_Id))
                {
                    vehicle.TripMeter += report.Distance.Value;
                }
                foreach (var item in DBContext.VehicleFuel)
                {
                    if (item.Vehicle_Id == vehicle.RegNr)
                    {
                        if (vehicle.PrimaryFuel_ID > 0)
                        {
                            vehicle.PrimaryFuel_ID = item.Fuel_Id;
                        }
                        else
                        {
                            vehicle.SecondaryFuel_ID = item.Fuel_Id;
                        }
                    }
                }
                list.Add(vehicle);
            }
            return(list);
        }
        public async Task LoadVehicleDetailsFromVin(string vin)
        {
            var vehicleDetails = await _vehicleInformationService.GetVehicleInformation(vin);

            CurrentVehicle = new VehicleModel()
            {
                VIN   = vehicleDetails.VIN,
                Make  = vehicleDetails.Make,
                Model = vehicleDetails.SelectedModel,
                Year  = vehicleDetails.Year
            };

            if (vehicleDetails.SelectedModel == null)
            {
                var models = vehicleDetails.VehicleModels.ToList();

                LoadVehicleDetailsModelRequired?.Invoke(new LoadVehicleDetailsModelRequiredResponse {
                    Success = true, Message = "Please select the vehicle's model.", ModelOptions = models
                });
                return;
            }

            await ProcessVehicleOptions(vehicleDetails);
        }
Esempio n. 23
0
        public async Task <VehicleModel> VehicleGet(int vehicleId)
        {
            VehicleModel model = null;

            if (vehicleId == 0)
            {
                model                    = new VehicleModel();
                model.VehicleId          = 0;
                model.VehicleType        = "";
                model.RegistrationNumber = "";
            }
            else
            {
                model = Mapper.Map <VehicleEntity, VehicleModel>(await GetSingleAsync <VehicleEntity>(vehicleId));
            }

            model.VehicleTypeList = await VehicleTypeListItemGet();

            model.ManufacturerList = await VehicleManufacturerListItemGet();

            model.VehicleModelList = await VehicleManufactureModelGet();

            return(model);
        }
Esempio n. 24
0
        public ActionResult GetOneVehiclesServiceHistory(VehicleModel vehicle)
        {
            var request = new VehicleDto {
                VehicleId = vehicle.VehicleId
            };
            var vehicleServiceList = new List <GetVehicleServicesModel>();

            string jsonrequest = JsonConvert.SerializeObject(request);
            var    httpcontent = new StringContent(jsonrequest, Encoding.UTF8, "application/json");

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString());

                var response = client.PostAsync(new Uri(_endpoints.GetVehiclesServiceHistory), httpcontent).Result;
                if (response != null)
                {
                    var jsonGetVehicleServices = response.Content.ReadAsStringAsync().Result;
                    var responseDto            = JsonConvert.DeserializeObject <GetAllVehicleServicesResponseDto>(jsonGetVehicleServices);

                    foreach (var service in responseDto.VehicleServices)
                    {
                        var vehicleServices = new GetVehicleServicesModel
                        {
                            VehicleServiceId = service.VehicleServiceId,
                            VehicleId        = service.VehicleId,
                            ServiceDate      = service.ServiceDate,
                            ServiceType      = service.ServiceType
                        };
                        vehicleServiceList.Add(vehicleServices);
                    }
                    ViewBag.Message = vehicleServiceList;
                }
            }
            return(View("GetAllServiceHistories", vehicleServiceList));
        }
Esempio n. 25
0
        public void TestBadUpdate()
        {
            using (WebClient client = new WebClient())
            {
                VehicleModel civic = new VehicleModel
                {
                    Id    = 1,
                    Make  = "Honda",
                    Model = "Civic",
                    Year  = 2000
                };

                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                try
                {
                    client.UploadString("http://localhost:62801/vehicles/1", "PUT", JsonConvert.SerializeObject(civic));
                }
                catch (WebException e)
                {
                    Assert.IsTrue(true);
                }
            }
        }
        public void UpdateVehicleModel(int id, string name, VehicleModel vehicleModel)
        {
            //vehicleModel.name = name;

            int itemIndex;

            foreach (VehicleModel vm in lVehicleModel.ToList())
            {
                if (vm.id == id)
                {
                    /*
                     * Nije radilo pa sam morao raditi na pokušaj iznad
                     *
                     * vm.name = name;
                     * vm.abrv = abrv;
                     *
                     */
                    itemIndex = lVehicleModel.IndexOf(vm);
                    lVehicleModel.Remove(vm);
                    lVehicleModel.Insert(itemIndex, new VehicleModel(vm.id, vm.makeId, name, vm.abrv));
                }
            }
            //lVehicleModel = new ObservableCollection<VehicleMake>(lVehicleModel);
        }
Esempio n. 27
0
        public void _203_AddVehicleWithVinIsNot17Char()
        {
            vehiclePage.AddVehicleBtn.Click();

            addNewVehiclePage = new AddEditNewVehiclePage(_driver);
            Assert.IsTrue(addNewVehiclePage.IsDisplayed());

            vehicle = new VehicleModel();

            addNewVehiclePage.MakeInputField.SendKeys(vehicle.Make);
            addNewVehiclePage.ModelInputField.SendKeys(vehicle.Model);
            addNewVehiclePage.YearInputField.SendKeys(vehicle.Year);
            addNewVehiclePage.VinInputField.SendKeys(vehicle.VinIsNot17Char);
            addNewVehiclePage.DescriptionInputField.SendKeys(vehicle.Descriptopn);

            addNewVehiclePage.SaveBtn.Click();

            Assert.IsTrue(addNewVehiclePage.ElementIsShown(addNewVehiclePage.ValidatioinError));
            Assert.IsTrue(addNewVehiclePage.ElementIsShown(addNewVehiclePage.ValidatioinErrorMessage));
            Assert.AreEqual("VIN must consist of 17 alphanumeric characters.",
                            addNewVehiclePage.ValidatioinErrorMessage.Text);

            addNewVehiclePage.VehiclesTabLink.Click();
        }
Esempio n. 28
0
        public void TestUpdate()
        {
            using (WebClient client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                VehicleModel prius = new VehicleModel
                {
                    Id    = 1,
                    Make  = "Toyota",
                    Model = "Prius",
                    Year  = 2012
                };

                client.UploadString("http://localhost:62801/vehicles", JsonConvert.SerializeObject(prius));

                VehicleModel civic = new VehicleModel
                {
                    Id    = 1,
                    Make  = "Honda",
                    Model = "Civic",
                    Year  = 2000
                };

                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                client.UploadString("http://localhost:62801/vehicles/1", "PUT", JsonConvert.SerializeObject(civic));

                string storedData = client.DownloadString("http://localhost:62801/vehicles");
                List <VehicleModel> storedModel = JsonConvert.DeserializeObject <List <VehicleModel> >(storedData);

                Assert.AreEqual(storedModel[0].Make, "Honda");

                client.UploadValues("http://localhost:62801/vehicles/1", "DELETE", new NameValueCollection());
            }
        }
        public ActionResult CreateVehicle(VehicleModel networkVehicle)
        {
            try
            {
                var marketRepresentation = Repository.GetMarket(networkVehicle.Market);
                marketRepresentation.Vehicles.Add(new Vehicle
                {
                    Id                  = Guid.NewGuid().ToString(),
                    Name                = networkVehicle.Name,
                    LogoName            = networkVehicle.LogoName,
                    MaxNumberPassengers = networkVehicle.MaxNumberPassengers,
                    NetworkVehicleId    = GenerateNextSequentialNetworkVehicleId()
                });
                Repository.Update(marketRepresentation);
            }
            catch (Exception)
            {
                ViewBag.Error = "An error occured. Unable to create the vehicle.";

                return(View(networkVehicle));
            }

            return(RedirectToAction("MarketIndex", GetMarketModel(networkVehicle.Market)));
        }
        public ActionResult Create([Bind(Include = "Id,VehicleBrandId,Name,MaxPassengers,BigLuggage")] VehicleModel vehicleModel)
        {
            var error = string.Empty;

            if (ModelState.IsValid)
            {
                try
                {
                    vehicleModel.Id = Guid.NewGuid();
                    db.VehicleModels.Add(vehicleModel);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (DbUpdateException ex)
                {
                    error = ex.GetDeepestMessage();
                }
            }

            ViewBag.VehicleBrandId = new SelectList(db.VehicleBrands, "Id", "Name", vehicleModel.VehicleBrandId);
            ViewBag.Error          = error;

            return(View(vehicleModel));
        }
Esempio n. 31
0
        public void ComboboxInitialize()
        {
            comboBoxCategory.DataSource    = VehicelCategoryBusiness.getVehicleCatmakmodel("VehicleCategory");
            comboBoxCategory.DisplayMember = "Name";
            comboBoxCategory.ValueMember   = "VehicleCategoryId";



            try
            {
                VehicleMaker maker = new VehicleMaker()
                {
                    VehicleCategoryId = Convert.ToInt32(comboBoxCategory.SelectedValue.ToString())
                };
                comboBoxMaker.DataSource    = new RateCardBusiness().getMakerFromCategory(maker);
                comboBoxMaker.DisplayMember = "Maker";
                comboBoxMaker.ValueMember   = "VehicleMakerID";
            }
            catch (Exception ex)
            {
            }

            try
            {
                VehicleModel model = new VehicleModel()
                {
                    vehicle_maker_id = Convert.ToInt32(comboBoxMaker.SelectedValue.ToString())
                };
                comboBoxModel.DataSource    = new RateCardBusiness().getModelFromMaker(model);
                comboBoxModel.DisplayMember = "Model";
                comboBoxModel.ValueMember   = "VehicleModelID";
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 32
0
        public async void VehicleUpdate()
        {
            // Arrange
            this.VehicleTable();
            await this.SaveChangesAsync(this.FleetDbContext);

            VehicleModel model = new VehicleModel() { VehicleId = 1, RegistrationNumber = "AP12345", VehicleManufacturerId = 1, VehicleModelId = 1, VehicleTypeId = 1 };

            // Act
            AjaxModel<NTModel> ajaxModel = await this.Controller.VehicleUpdate(model);

            // Assert
            VehicleEntity entity = this.FleetDbContext.Vehicles.First(m => m.VehicleId == model.VehicleId);
            Assert.Equal(entity.RegistrationNumber, "AP12345");
            Assert.Equal(ajaxModel.Message, FleetMessages.VehicleSaveSuccess);
        }
Esempio n. 33
0
 private void LoadModel()
 {
     try
     {
         var carfile = new VehicleFile(GameVars.BasePath + "cars\\" + _info.FileName);
         _model = new VehicleModel(carfile, true);
     }
     catch (Exception ex)
     {
         _loadException = "Error: " + ex.Message;
     }
 }
Esempio n. 34
0
        public async void VehicleAdd()
        {
            // Arrange
            VehicleModel model = new VehicleModel() { VehicleId = 0, RegistrationNumber = "AP12345", VehicleManufacturerId = 1, VehicleModelId = 1, VehicleTypeId = 1 };

            // Act
            AjaxModel<NTModel> ajaxModel = await this.Controller.VehicleAdd(model);

            // Assert
            VehicleEntity entity = this.FleetDbContext.Vehicles.Last();
            Assert.Equal(entity.RegistrationNumber, "AP12345");
            Assert.Equal(ajaxModel.Message, FleetMessages.VehicleSaveSuccess);
        }
Esempio n. 35
0
        public ContractPage(BuildVehicleVM vm, VehicleModel v)
        {
            InitializeComponent();

            DataContext = new ContractVM(vm, v);
        }
        private void LoadModel()
        {
            _file = new FileInfo(Application.StartupPath + @"\\Vehicle.xlsx");

            using (var package = new ExcelPackage(_file))
            {
                var workbook = package.Workbook;

                using (var tx = NHibernateSessionManager.GetLocalSession().BeginTransaction())
                {
                    var ws = workbook.Worksheets[@"Model"];
                    var brands = _vehicleBrandRepository.GetAll();

                    for (var i = 1; i < ws.Dimension.End.Row + 1; i++)
                    {
                        VehicleSize size;

                        Enum.TryParse(ws.Cells[i, 3].Value.ToString(), out size);

                        var newModel = new VehicleModel(
                            ws.Cells[i, 1].Value.ToString(),
                            ws.Cells[i, 2].Value.ToString(),
                            brands.FirstOrDefault(x => x.Code == ws.Cells[i, 3].Value.ToString()),
                            size,
                            VehicleType.CAR
                        );

                        _vehicleModelRepository.Insert(newModel);
                    }

                    tx.Commit();
                }
            }
        }
Esempio n. 37
0
        public void UnparkCommand(Client player, int vehicleId)
        {
            VehicleModel vehicle = Vehicles.GetParkedVehicleById(vehicleId);

            if (vehicle == null)
            {
                // There's no vehicle with that identifier
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_VEHICLE_NOT_EXISTS);
            }
            else if (Vehicles.HasPlayerVehicleKeys(player, vehicle) == false)
            {
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_CAR_KEYS);
            }
            else
            {
                foreach (ParkingModel parking in parkingList)
                {
                    if (player.Position.DistanceTo(parking.position) < 2.5f)
                    {
                        // Check whether the vehicle is in this parking
                        if (parking.id == vehicle.parking)
                        {
                            int playerMoney = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_MONEY);

                            switch (parking.type)
                            {
                            case Constants.PARKING_TYPE_PUBLIC:
                                break;

                            case Constants.PARKING_TYPE_SCRAPYARD:
                                break;

                            case Constants.PARKING_TYPE_DEPOSIT:
                                // Remove player's money
                                if (playerMoney >= Constants.PRICE_PARKING_DEPOSIT)
                                {
                                    NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, playerMoney - Constants.PRICE_PARKING_DEPOSIT);

                                    String message = String.Format(Messages.INF_UNPARK_MONEY, Constants.PRICE_PARKING_DEPOSIT);
                                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + message);
                                }
                                else
                                {
                                    String message = String.Format(Messages.ERR_PARKING_NOT_MONEY, Constants.PRICE_PARKING_DEPOSIT);
                                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + message);
                                    return;
                                }
                                break;
                            }

                            // Get parked vehicle model
                            ParkedCarModel parkedCar = GetParkedVehicle(vehicleId);

                            // Recreate the vehicle
                            Vehicle newVehicle = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(vehicle.model), parking.position, vehicle.rotation.Z, new Color(0, 0, 0), new Color(0, 0, 0));
                            NAPI.Vehicle.SetVehicleNumberPlate(newVehicle, vehicle.plate == String.Empty ? "LS " + (1000 + vehicle.id) : vehicle.plate);
                            NAPI.Vehicle.SetVehicleEngineStatus(newVehicle, false);
                            NAPI.Vehicle.SetVehicleLocked(newVehicle, false);

                            if (vehicle.colorType == Constants.VEHICLE_COLOR_TYPE_PREDEFINED)
                            {
                                NAPI.Vehicle.SetVehiclePrimaryColor(newVehicle, Int32.Parse(vehicle.firstColor));
                                NAPI.Vehicle.SetVehicleSecondaryColor(newVehicle, Int32.Parse(vehicle.secondColor));
                                NAPI.Vehicle.SetVehiclePearlescentColor(newVehicle, vehicle.pearlescent);
                            }
                            else
                            {
                                String[] firstColor  = vehicle.firstColor.Split(',');
                                String[] secondColor = vehicle.secondColor.Split(',');
                                NAPI.Vehicle.SetVehicleCustomPrimaryColor(newVehicle, Int32.Parse(firstColor[0]), Int32.Parse(firstColor[1]), Int32.Parse(firstColor[2]));
                                NAPI.Vehicle.SetVehicleCustomSecondaryColor(newVehicle, Int32.Parse(secondColor[0]), Int32.Parse(secondColor[1]), Int32.Parse(secondColor[2]));
                            }

                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_ID, vehicle.id);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_MODEL, vehicle.model);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_POSITION, parking.position);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_ROTATION, vehicle.rotation);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_COLOR_TYPE, vehicle.colorType);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_FIRST_COLOR, vehicle.firstColor);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_SECOND_COLOR, vehicle.secondColor);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_PEARLESCENT_COLOR, vehicle.pearlescent);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_FACTION, vehicle.faction);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_PLATE, vehicle.plate);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_OWNER, vehicle.owner);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_PRICE, vehicle.price);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_GAS, vehicle.gas);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_KMS, vehicle.kms);

                            // Update parking values
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_DIMENSION, 0);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_PARKING, 0);
                            NAPI.Data.SetEntityData(newVehicle, EntityData.VEHICLE_PARKED, 0);

                            // Add tunning
                            Mechanic.AddTunningToVehicle(newVehicle);

                            // Unlink from the parking
                            parkedCars.Remove(parkedCar);

                            return;
                        }

                        // The vehicle is not in this parking
                        NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_VEHICLE_NOT_THIS_PARKING);
                        return;
                    }
                }

                // Player's not in any parking
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NOT_PARKING_NEAR);
            }
        }
Esempio n. 38
0
 // Inherit the vehicle model
 protected override void Awake()
 {
     base.Awake();
     model = item as VehicleModel;
 }