Edit Records

This commit is contained in:
2025-12-01 17:56:17 +01:00
parent 7ea5ed506e
commit c8ded1f0a4
11 changed files with 624 additions and 28 deletions

View File

@@ -56,4 +56,38 @@ public class LayerService
// For now we don't need it for read-only view
return await Task.FromResult(false);
}
public async Task<RecordDto?> CreateRecordAsync(Guid layerId, RecordDto record)
{
var response = await _httpClient.PostAsJsonAsync($"Layers/{layerId}/records", record);
if (!response.IsSuccessStatusCode)
{
var error = await response.Content.ReadAsStringAsync();
Console.Error.WriteLine($"CreateRecordAsync failed: {response.StatusCode} - {error}");
return null;
}
return await response.Content.ReadFromJsonAsync<RecordDto>();
}
public async Task<RecordDto?> UpdateRecordAsync(Guid layerId, Guid recordId, RecordDto record)
{
var response = await _httpClient.PutAsJsonAsync($"Layers/{layerId}/records/{recordId}", record);
if (!response.IsSuccessStatusCode)
{
var error = await response.Content.ReadAsStringAsync();
Console.Error.WriteLine($"UpdateRecordAsync failed: {response.StatusCode} - {error}");
return null;
}
return await response.Content.ReadFromJsonAsync<RecordDto>();
}
public async Task<bool> DeleteRecordAsync(Guid layerId, Guid recordId)
{
var response = await _httpClient.DeleteAsync($"Layers/{layerId}/records/{recordId}");
return response.IsSuccessStatusCode;
}
}