public async Task<KraniumEntity> CreateKraniumAsync(KraniumEntity kranium) { if (await GetKraniumAsync() != null) return null; KraniumEntity kraniumToCreate = Context.Kranium.Add(kranium); await SaveAsync(); return kraniumToCreate; }
public async Task<KraniumEntity> UpdateKraniumAsync(KraniumEntity kranium) { KraniumEntity kraniumToUpdate = await GetKraniumAsync(); if (kraniumToUpdate == null) return await CreateKraniumAsync(new KraniumEntity()); if (kranium.Name != null) kraniumToUpdate.Name = kranium.Name; if (kranium.Version != null) kraniumToUpdate.Version = kranium.Version; if (kranium.MacAddress != null) kraniumToUpdate.MacAddress = kranium.MacAddress; if (kranium.IPAddress != null) kraniumToUpdate.IPAddress = kranium.IPAddress; if (kranium.ZigBeePanId != null) kraniumToUpdate.ZigBeePanId = kranium.ZigBeePanId; if (kranium.ZigBeeChannel != null) kraniumToUpdate.ZigBeeChannel = kranium.ZigBeeChannel; if (kranium.ZigBeeMacAddress != null) kraniumToUpdate.ZigBeeMacAddress = kranium.ZigBeeMacAddress; await SaveAsync(); return kraniumToUpdate; }