public ViewResult AddSheet() { AddSheetViewModel sheet = new AddSheetViewModel(); using (DriverRepository repo = new DriverRepository()) { sheet.Drivers = (from d in repo.Drivers select new DriverSheetViewModel() { Id = d.Id, Name = d.Rg.Name }).ToList<DriverSheetViewModel>(); } using (VehicleRepository repo = new VehicleRepository()) { sheet.Trucks = (from t in repo.Vehicles where t.Type.Equals("Caminhão") select new VehicleSheetViewModel() { Id = t.Id, Plate = t.Plate, SecondaryPlate = null }).ToList<VehicleSheetViewModel>(); sheet.Carts = (from c in repo.Vehicles where (c.Type.Equals("Carreta") || c.Type.Equals("Bi-Trem")) select new VehicleSheetViewModel() { Id = c.Id, Plate = c.Plate, SecondaryPlate = c.SecondaryVehicle.Plate }).ToList<VehicleSheetViewModel>(); } return View(sheet); }
public DriverController() { this.repository = new DriverRepository(); }