コード例 #1
0
 public ActionResult PersonDetails(int id)
 {
     Person person;
     using (MyItemsDbcontext Db = new MyItemsDbcontext())
     {
         person = Db.People.Include("Belongings").Include("Belongings.LentBy").SingleOrDefault(p => p.Id == id);
     }
     if (person == null)
     {
         return new HttpStatusCodeResult(404);
     }
     return PartialView("_PersonDetails",person);
 }
コード例 #2
0
        public ActionResult Index()
        {
            List<Person> personList;
            using (MyItemsDbcontext Db = new MyItemsDbcontext())
            {
                personList = Db.People.ToList();
            }
            if (personList == null)
            {
                personList = new List<Person>();
                // add in errormessage to the user that no connection to Db was established.
            }
            return View(personList);

        }
コード例 #3
0
        public ActionResult Index()
        {
            List <Person> personList;

            using (MyItemsDbcontext db = new MyItemsDbcontext())
            {
                personList = db.People.ToList();
            }

            if (personList == null)
            {
                personList = new List <Person>();
            }
            return(View(personList));
        }