Пример #1
0
        public IActionResult register()
        {
            string cs = @"server=localhost;userid=root;password=;database=goa_ss";

            var con = new MySqlConnection(cs);

            con.Open();

            string sql = "SELECT * FROM anime";
            var    cmd = new MySqlCommand(sql, con);

            MySqlDataReader rdr = cmd.ExecuteReader();

            int i = 0;
            List <Entity.Anime> anime = new List <Entity.Anime>();

            while (rdr.Read())
            {
                Entity.Anime a = new Entity.Anime();
                a.id      = rdr.GetInt32(0);
                a.history = rdr.GetString(5);
                a.image   = rdr.GetString(6);
                a.name    = rdr.GetString(8);
                anime.Add(a);
            }

            return(View(anime));
        }
Пример #2
0
        public IActionResult info()
        {
            string cs = @"server=localhost;userid=root;password=;database=goa_ss";

            var con = new MySqlConnection(cs);

            con.Open();

            string sql = "SELECT * FROM anime Where id = " + id;
            var    cmd = new MySqlCommand(sql, con);

            MySqlDataReader rdr = cmd.ExecuteReader();

            Entity.Anime anime = new Entity.Anime();

            while (rdr.Read())
            {
                anime.id      = rdr.GetInt32(0);
                anime.date    = rdr.GetString(3);
                anime.genre   = rdr.GetString(4);
                anime.history = rdr.GetString(5);
                anime.image   = rdr.GetString(6);
                anime.name    = rdr.GetString(8);
            }

            ViewData["name"]    = anime.name;
            ViewData["history"] = anime.history;
            ViewData["date"]    = anime.date;
            ViewData["genre"]   = anime.genre;
            ViewData["image"]   = anime.image;

            return(View());
        }