This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IActionResult> Upsert(BulkUpsertRequest request) | |
{ | |
request.Devices.ForEach(d => | |
{ | |
var device = new Device(d.Id, d.Name, d.Metadata.Select(...)); | |
_dbContext.Entry(device).IsModified = true; | |
}) | |
await _dbContext.SaveAsync(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DeviceService.Api.Contracts; | |
public record DeviceMetadata(Guid MetadataFieldId, System.Text.Json.JsonElement Value); | |
public record DeviceToCreate(Guid DeviceTypeId, string DeviceName, IList<DeviceMetadata> MetaData); | |
public record BulkCreateDevicesRequest(IList<DeviceToCreate> Devices); | |
/* | |
Example: |