Beispiel #1
0
        public DevicesResponse Put([FromBody] Device device)
        {
            if (device == null)
            {
                return(new DevicesResponse($"{nameof(device)} cannot be null"));
            }

            if (device.Id != 0)
            {
                return(new DevicesResponse($"{nameof(device.Id)} must be 0"));
            }

            try
            {
                _physicalAddressParser.Parse(device.MacAddress);
                var insertedDevice = _wolSharpDbContext.Devices.Add(device);
                _wolSharpDbContext.SaveChanges();
                return(new DevicesResponse {
                    DeviceId = insertedDevice.Entity.Id
                });
            }
            catch (Exception e)
            {
                return(new DevicesResponse(e.Message));
            }
        }
Beispiel #2
0
        public async Task WakeAsync(string physicalAddress, byte[] password = null)
        {
            var address = _physicalAddressParser.Parse(physicalAddress);

            await SendWakeOnLanPacketAsync(address, password);
        }