Edit Records
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user