Example #1
0
 public User Create(User inputObject)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         context.Users.Add(inputObject);
         context.SaveChanges();
         return inputObject;
     }
 }
Example #2
0
        public User Update(User inputObject)
        {
            using (GoKeyboardDbContext context = new GoKeyboardDbContext())
            {
                context.Users.Attach(inputObject);
                context.Entry(inputObject).State = EntityState.Modified;

                    context.SaveChanges();
                    return inputObject;
            }
        }
Example #3
0
 public void Delete(int id)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         User UserFromDb = context.Users.Where(u => u.Id == id).FirstOrDefault();
         if (UserFromDb == null)
             throw new KeyboardDalException("Utilisateur introuvable en base de données");
         context.Users.Remove(UserFromDb);
         context.SaveChanges();
     }
 }