public Client Update(Client aClient) { Client gevonden = null; using (KfsContext ctx = new KfsContext(_constring)) { gevonden = ctx.Set <Client>() .FirstOrDefault(u => u.Id == aClient.Id); if (gevonden == null) { throw new DuplicateNameException($"user with {aClient.FirstName} not exist"); } ctx.Entry(gevonden).CurrentValues.SetValues(aClient); ctx.Entry(gevonden.CltAddresss.ToList()[0]).CurrentValues.SetValues(aClient.CltAddresss.ToList()[0]); ctx.SaveChanges(); } return(gevonden); }
public Employee Update(Employee aEmployee) { Employee gevonden = null; using (KfsContext ctx = new KfsContext(_constring)) { gevonden = ctx.Set <Employee>() .FirstOrDefault(u => u.Id == aEmployee.Id); if (gevonden == null) { throw new DuplicateNameException($"user with {aEmployee.FirstName} not exist"); } ctx.Entry(gevonden).CurrentValues.SetValues(aEmployee); ctx.Entry(gevonden.EmpAddress).CurrentValues.SetValues(aEmployee.EmpAddress); ctx.Entry(gevonden.EmpContract).CurrentValues.SetValues(aEmployee.EmpContract); ctx.Entry(gevonden.EmpAppAccount).CurrentValues.SetValues(aEmployee.EmpAppAccount); ctx.SaveChanges(); } return(gevonden); }
public Product Update(Product aProduct) { Product gevonden = null; using (KfsContext ctx = new KfsContext(_constring)) { gevonden = ctx.Set <Product>() .FirstOrDefault(u => u.EAN == aProduct.EAN); if (gevonden == null) { throw new DuplicateNameException($"user with {aProduct.EAN} not exist"); } ctx.Entry(gevonden).CurrentValues.SetValues(aProduct); //ctx.Entry(gevonden.EmpAddress).CurrentValues.SetValues(aEmployee.EmpAddress); //ctx.Entry(gevonden.EmpContract).CurrentValues.SetValues(aEmployee.EmpContract); //ctx.Entry(gevonden.EmpAppAccount).CurrentValues.SetValues(aEmployee.EmpAppAccount); ctx.SaveChanges(); } return(gevonden); }