Hello Sir,
Below is the code for deleting data from database using web api, but here the data is not getting deleted. please help
//code for web api
public Response deleteprogressnotes(Progressnotes notes)
{
Response response = new Response();
try
{
SqlCommand cmd = new SqlCommand("crm_sp_delete_progressnotes", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@notesId", notes.notesId);
con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { response.Message = "Deleted successfully"; response.Status = 1; } else { response.Message = "Failed to delete" response.Status = 0; } } catch (Exception ex) { response.Message = ex.Message; response.Status = 0; } return response; }
code delete.xaml.cs
private async void Button_Clicked_1(object sender, EventArgs e)
{
Progressnotes progress = new Progressnotes();
progress.notesId = Convert.ToInt32(notes.Text);
string url = "http://******/api/Delete/deleteprogressnotes";
HttpClient client = new HttpClient();
string JsonData = JsonConvert.SerializeObject(progress);
StringContent content = new StringContent(JsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.DeleteAsync(url);
string result = await response.Content.ReadAsStringAsync();
Response responsedata = JsonConvert.DeserializeObject(result);
if (responsedata.Status == 1)
{
await Navigation.PushAsync(new Progress_notes());
NavigationPage.SetHasNavigationBar(this, true);
}
else
{
noelse.Text = "Welcome";
} }
Please help
Thanks