I have defined a Restful-Api Data Source which has a Delete Method configured like this:
It seems to what looks like reasonable code in the Service for the DataSource like this:
public async Task DeleteContributor(int id)
{
var uri = new Uri(httpClient.BaseAddress, $"Contributors/{id}");
var request = new HttpRequestMessage(HttpMethod.Delete, uri);
OnDeleteContributor(request);
var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
OnDeleteContributorResponse(response);
}
However the code in the Grid for the Delete Button is expecting a Deletion Result:
protected async Task GridDeleteButtonClick(MouseEventArgs args, AAF2.RadzenStudio.API.Server.Models.AAF2.Contributor contributor)
{
try
{
if (await DialogService.Confirm("Are you sure you want to delete this record?") == true)
{
var deleteResult = await AAF2Service.DeleteContributor(contributor.Id);
if (deleteResult != null)
{
await grid0.Reload();
}
}
}
catch (Exception ex)
{
NotificationService.Notify(new NotificationMessage
{
Severity = NotificationSeverity.Error,
Summary = $"Error",
Detail = $"Unable to delete Contributor"
});
}
}
I've looked for an example of deletion in the documentation and the sample apps but there isn't one I can find, what should this code look like ?