Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }