コード例 #1
0
        public ActionResult List()
        {
            var context = new DataClassesDataContext();
            var voyages = context.Voyages.ToList();

            return View(voyages);
        }
コード例 #2
0
 public ActionResult Index()
 {
     using (var context = new DataClassesDataContext())
     {
         var cargos = context.Cargos.ToList();
         return View(cargos);
     }
 }
コード例 #3
0
 public ActionResult Index()
 {
     using (var context = new DataClassesDataContext())
     {
         var voyages = context.Voyages.ToList();
         return View(voyages);
     }
 }
コード例 #4
0
        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() };
                }
            }
        }