public void RemoveById(int alarmId) { var alarm = _context.Alarms.FirstOrDefault(c => c.AlarmId == alarmId); if (alarm == null) { throw new ExpectException("Could not find data which AlarmId equal to " + alarmId); } _context.Remove(alarm); _context.SaveChanges(); }
public void RemoveById(int logId) { var log = _context.Logs.FirstOrDefault(c => c.LogId == logId); if (log == null) { throw new ExpectException("Could not find data which LogId equal to " + logId); } _context.Remove(log); _context.SaveChanges(); }
public void RemoveById(int locationId) { var location = _context.Locations.FirstOrDefault(l => l.LocationId == locationId); if (location == null) { throw new ExpectException("Could not find data which DeviceLocation equal to " + locationId); } _context.Remove(location); _context.SaveChanges(); }
public void RemoveById(int deviceId) { var device = _context.Devices.FirstOrDefault(l => l.DeviceId == deviceId); if (device == null) { throw new ExpectException("Could not find data which DeviceId equal to " + deviceId); } _context.Remove(device); _context.SaveChanges(); }
public void RemoveById(int userGroupId) { var userGroup = _context.UserGroups.FirstOrDefault(c => c.UserGroupId == userGroupId); if (userGroup == null) { throw new ExpectException("Could not find data which UserGroupId equal to " + userGroupId); } _context.Remove(userGroup); _context.SaveChanges(); }
public void RemoveById(int groupLocationId) { var groupLocation = _context.GroupLocations.FirstOrDefault(c => c.GroupLocationId == groupLocationId); if (groupLocation == null) { throw new ExpectException("Could not find data which groupLocationId equal to " + groupLocationId); } _context.Remove(groupLocation); _context.SaveChanges(); }
public async Task RemoveByIdAsync(int sceneId) { //When delete Scenes,dependent group's foreign key (SceneId) will be SetNull var scene = _context.Scenes.Include(c => c.Groups).FirstOrDefault(c => c.SceneId == sceneId); if (scene == null) { throw new ExpectException("Could not find data which SceneId equal to " + sceneId); } _context.Remove(scene); await _context.SaveChangesAsync(); }