public void Update(User entity)
 {
     using (var db = new AppEntities())
     {
         db.Entry(entity).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void Add(User entity)
 {
     using (var db = new AppEntities())
     {
         db.Users.Add(entity);
         db.SaveChanges();
     }
 }
 public void Delete(int id)
 {
     using (var db = new AppEntities())
     {
         User userToDelete = db.Users.Find(id);
         if (userToDelete != null)
         {
             db.Users.Remove(userToDelete);
             db.SaveChanges();
         }
     }
 }