public JsonResult Put(WomenShoes shoe) { string query = @" update dbo.womenshoes set WomenShoesName = '" + shoe.WomenShoesName + @"' ,WomenShoesPrice = '" + shoe.WomenShoesPrice + @"' ,WomenShoesQuantity = '" + shoe.WomenShoesQuantity + @"' ,WomenShoesPhoto = '" + shoe.WomenShoesPhoto + @"' where WomenShoesID = " + shoe.WomenShoesID + @" "; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("ClothesAppCon"); 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 Successful")); }
public JsonResult Post(WomenShoes shoe) { string query = @" insert into dbo.womenshoes (WomenShoesName, WomenShoesPrice, WomenShoesQuantity, WomenShoesPhoto) values ( '" + shoe.WomenShoesName + @"' ,'" + shoe.WomenShoesPrice + @"' ,'" + shoe.WomenShoesQuantity + @"' ,'" + shoe.WomenShoesPhoto + @"' )"; DataTable table = new DataTable(); string sqlDataSource = _configuration.GetConnectionString("ClothesAppCon"); 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 Successful")); }