public static StatistikaModel GetAllStatistika() { StatistikaModel model = null; SqlConnection connection = Database.GetConnection(); SqlCommand cmd = null; SqlDataReader reader = null; connection.Open(); cmd = new SqlCommand(GET_ALL_STATISTIKA, connection); cmd.CommandTimeout = 60; reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); model = new StatistikaModel(); model.TipskaOdobrenjaCount = reader.GetInt32(0); model.SertifikatiCount = reader.GetInt32(1); model.ProizvodjaciCount = reader.GetInt32(2); model.MarkeCount = reader.GetInt32(3); reader.Close(); } connection.Close(); return(model); }
public ActionResult Index() { try { HttpContext.Session.SetObjectAsJson("LogovaniKorisnik", null); StatistikaModel statistikaModel = KorisnikDAO.GetAllStatistika(); ViewBag.TipskihOdobrenjaCount = statistikaModel.TipskaOdobrenjaCount.ToString(); ViewBag.SertifikataCount = statistikaModel.SertifikatiCount.ToString(); ViewBag.ProizvodjacaCount = statistikaModel.ProizvodjaciCount.ToString(); ViewBag.MarkeCount = statistikaModel.MarkeCount.ToString(); return(View()); } catch (Exception) { return(View()); } }