コード例 #1
0
 private int GetQuoteCounts()
 {
     using( var db = new QuoteDBEntities())
     {
         return db.Quotes.Count();
     }
 }
コード例 #2
0
        //
        // GET: /Quote/
        public ActionResult Index()
        {
            using(var db = new QuoteDBEntities())
            {

                return View(db.Quotes.ToList());
            }
        }
コード例 #3
0
        public ActionResult RandomQuote()
        {
            using(var db = new QuoteDBEntities())
            {
                Random rnd = new Random((int)DateTime.Now.Ticks);

                var model = db.Quotes.Find(rnd.Next(1, GetQuoteCounts()+1));

                return View(model);
             }
        }