Пример #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);
             }
        }