public ActionResult RegisterCar(CarsCompanyViewModel viewModel) { var userId = User.Identity.GetUserId(); var company = _companyService.GetAll().First(x => x.UserId == userId); var newcar = (new Car() { Brand = viewModel.Brand, InternalNumber = viewModel.InternalNumber, Model = viewModel.Model, RegisterNumber = viewModel.RegisterNumber, Year = viewModel.Year, Company = company, Location = new Location() { Latitude = 0, Longitude = 0 }, CarStatus = CarStatus.OffDuty, LastActiveDateTime = DateTime.Now }); _carService.CreateCar(newcar); if (viewModel.SelectedDriver != "0") { var driver = _driverService.GetAll().First(x => x.UserId == viewModel.SelectedDriver); _driverService.AddCar(driver.Id, newcar); } return(RedirectToAction("Cars")); }