public JsonResult Put(Pozitat poz) { string query = @" update Pozita set Pozita= '" + poz.Pozita + @"' where Id = " + poz.Id + @" "; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("ElavingApp"); SqlDataReader myReader; using (SqlConnection myCon = new SqlConnection(sqlDataSource)) { myCon.Open(); using (SqlCommand myCommand = new SqlCommand(query, myCon)) { myReader = myCommand.ExecuteReader(); table.Load(myReader);; myReader.Close(); myCon.Close(); } } return(new JsonResult("Updated Successfully")); }
public JsonResult Post(Pozitat poz) { string query = @" insert into Pozita values ('" + poz.Pozita + @"') "; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("ElavingApp"); SqlDataReader myReader; using (SqlConnection myCon = new SqlConnection(sqlDataSource)) { myCon.Open(); using (SqlCommand myCommand = new SqlCommand(query, myCon)) { myReader = myCommand.ExecuteReader(); table.Load(myReader);; myReader.Close(); myCon.Close(); } } return(new JsonResult("Added Successfully")); }