public void UpdateClientAvailabilityStatus(Client client) { //using (var ctx = new LANBackupContext1()) //{ // var dbClient = ctx.Clients.FirstOrDefault(p => p.ClientId == client.ClientId); // if (dbClient == null) // ctx.Clients.Add(client); // else dbClient.isAvailable = client.isAvailable; // ctx.SaveChanges(); //} }
private void CreateClient(Client client) { using (var ctx = new LANBackupContext()) { var dbclient = ctx.CLIENTs.FirstOrDefault(p => p.CLIENTID == client.ClientId); if (dbclient != null) { dbclient.ISAVAILABLE = client.isAvailable; ctx.SaveChanges(); } else { dbclient = new CLIENT { CLIENTID = client.ClientId, ISAVAILABLE = client.isAvailable }; ctx.CLIENTs.Add(dbclient); ctx.SaveChanges(); } } }