Exemplo n.º 1
0
        public ActionResult Edit(OgrModel ogrenci)
        {
            _Repostory.Edit(ogrenci);
            return(RedirectToAction("Index"));

            /*
             * if (ModelState.IsValid)
             * {
             *  using (var con = new MySqlConnection("datasource=localhost;port=3306;Database=ogrdb;username=root;password=1234"))
             *  {
             *      con.Open();
             *      var cmd = new MySqlCommand("UPDATE Ogrenciler SET Ad = @Ad, Soyad =  @Soyad, Tc= @Tc WHERE Id = @Id", con);
             *      cmd.Parameters.AddWithValue("Id", ogrenci.Id);
             *      cmd.Parameters.AddWithValue("Ad", ogrenci.Ad);
             *      cmd.Parameters.AddWithValue("Soyad", ogrenci.Soyad);
             *      cmd.Parameters.AddWithValue("Tc", ogrenci.Tc);
             *
             *
             *      cmd.ExecuteNonQuery();
             *      con.Close();
             *      return RedirectToAction("Index");
             *  }
             * }
             *
             * return View(ogrenci);
             */
        }
Exemplo n.º 2
0
        // POST: api/Home
        public bool Post([FromBody] OgrModel ogrenci)
        {
            if (ModelState.IsValid)
            {
                _Repostory.Insert(ogrenci);
                return(true);
            }
            else
            {
                return(false);

                throw new HttpResponseException(HttpStatusCode.BadRequest);    // how return status cood with booleans
            }

            /*
             * try
             * {
             *  _Repostory.Insert(ogrenci);
             *  return true;
             * }
             * catch (Exception)
             * {
             *  throw new HttpResponseException(HttpStatusCode.BadRequest);
             *
             *  return false;
             * }
             */
        }
Exemplo n.º 3
0
        public ActionResult Insert(OgrModel ogrenci)
        {
            _Repostory.Insert(ogrenci);
            return(RedirectToAction("Index"));

            /*
             *          using (var con = new MySqlConnection("datasource=localhost;port=3306;Database=ogrdb;username=root;password=1234"))
             * {
             *  con.Open();
             *  var cmd = new MySqlCommand("INSERT INTO Ogrenciler (Ad , Soyad,Tc) VALUES (@Ad,  @Soyad, @Tc)", con);
             * // cmd.Parameters.AddWithValue("Id", ogrenci.Id);
             *  cmd.Parameters.AddWithValue("Ad", ogrenci.Ad);
             *  cmd.Parameters.AddWithValue("Soyad", ogrenci.Soyad);
             *  cmd.Parameters.AddWithValue("Tc", ogrenci.Tc);
             *
             *
             *  cmd.ExecuteNonQuery();
             *  con.Close();
             *  return RedirectToAction("Index");
             * }
             */
        }
Exemplo n.º 4
0
 // PUT: api/Home/5
 public void Put([FromBody] OgrModel ogrenci)
 {
     _Repostory.Edit(ogrenci);
 }