Ejemplo n.º 1
0
        // GET: Home
        // IRepostory<OgrModel> ogrRepository = new OgrRepostory();
        public ActionResult Index()
        {
            var ogrenciler = _Repostory.GetAll();

            return(View(ogrenciler));

            /*
             *
             * using (var con = new MySqlConnection("datasource=localhost;port=3306;Database=ogrdb;username=root;password=1234"))
             *  //try
             *  {
             *  con.Open();
             *  var cmd = new MySqlCommand("SELECT * FROM ogrenciler", con);
             *
             *  var reader = cmd.ExecuteReader();
             *  List<Models.OgrModel> ogrenciler = new List<OgrModel>();
             *  while (reader.Read())
             *  {
             *      Models.OgrModel ogrenci = new OgrModel()
             *      {
             *          Id = Convert.ToInt32(reader["Id"]),
             *          Ad = reader["Ad"].ToString(),
             *          Soyad = reader["Soyad"].ToString(),
             *          Tc = reader["Tc"].ToString()
             *
             *      };
             *      ogrenciler.Add(ogrenci);
             *  }
             * //  con.Close();//using default kapatıyor
             *  return View(ogrenciler);
             * }
             * // catch (Exception ex)
             * //{
             * //   Console.WriteLine(ex);
             * //  con.Close();
             * //  throw; //preserve stacktrace
             * // }*/
        }
Ejemplo n.º 2
0
        // GET: api/Home
        // readonly IRepostory<OgrModel> _Repostory;
        //public HomeController(IRepostory<OgrModel> ogrenci)
        //{
        //    //_Repostory = new OgrRepostory();

        //    _Repostory = ogrenci;
        //}

        public IEnumerable <OgrModel> Get()
        {
            return(_Repostory.GetAll());
        }