public ActionResult List() { var context = new DataClassesDataContext(); var voyages = context.Voyages.ToList(); return View(voyages); }
public ActionResult Index() { using (var context = new DataClassesDataContext()) { var cargos = context.Cargos.ToList(); return View(cargos); } }
public ActionResult Index() { using (var context = new DataClassesDataContext()) { var voyages = context.Voyages.ToList(); return View(voyages); } }
public static IEnumerable<SelectListItem> GetVoyageList() { using (var context = new DataClassesDataContext()) { yield return new SelectListItem() { Selected = true, Text = string.Empty, Value = null }; var result = context.Voyages.OrderBy(v => v.DepartureDate).ToList(); foreach (var item in result) { string departureDate = item.DepartureDate == null ? "unknown" : ((DateTime)item.DepartureDate).ToString("dd-MM-yyyy"); yield return new SelectListItem() { Selected = false, Text = "Departure: " + departureDate, Value = item.Id.ToString() }; } } }