public JsonResult Put(Puntoret pun) { string query = @" update dbo.Puntoret set EmriMbiemri = '" + pun.EmriMbiemri + @"' ,Mosha = '" + pun.Mosha + @"' ,Vendbanimi = '" + pun.Vendbanimi + @"' ,DataPranimit = '" + pun.DataPranimit + @"' ,Rroga = '" + pun.Rroga + @"' ,Titulli = '" + pun.Titulli + @"' where puntoretId = " + pun.puntoretId + @" "; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("RestaurantAppCon"); 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(Puntoret pun) { string query = @" insert into dbo.Puntoret (EmriMbiemri,Mosha,Vendbanimi,DataPranimit,Rroga,Titulli ) values ('" + pun.EmriMbiemri + @"', '" + pun.Mosha + @"', '" + pun.Vendbanimi + @"', '" + pun.DataPranimit + @"', '" + pun.Rroga + @"', '" + pun.Titulli + @"' )"; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("RestaurantAppCon"); 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")); }