public JsonResult Put(FestatZyrtare fz) { string query = @" update FestatZyrtare set Festa = '" + fz.Festa + @"', Dita = '" + fz.Dita + @"' where Id = " + fz.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("Update successfully")); }
public JsonResult Post(FestatZyrtare fz) { string query = @"insert into FestatZyrtare (Festa,Dita)values ( '" + fz.Festa + @"', '" + fz.Dita + @"' )"; 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")); }