public ActionResult AddCar(int locationId) { var c = new CarModel(); //c.Location = data.LocationRepository.GetLocationById(locationId); c.LocationId = locationId; c.ProductionTime = DateTime.Now; return View("AddCar", c); }
public ActionResult AddCarSave(CarModel car) { var c = new Car(); c.Made = car.Made; c.NumberOfOwners = car.NumberOfOwners; c.ProductionTime = DateTime.Now; c.Type = car.Type; c.Condition = car.Condition; using (var data = new Provider()) { c.Location = data.LocationRepository.GetLocationById( car.LocationId ); data.CarRepository.Add(c); return View("ListLocationsForCars", data.LocationRepository.GetAllLocation()); } }