Exemple #1
0
 public user find(int id)
 {
     using (userDBContext db = new userDBContext())
     {
         user u = db.users.Find(id);
         return(u);
     }
 }
Exemple #2
0
 public IEnumerable <user> getAllUser()
 {
     using (userDBContext db = new userDBContext())
     {
         IEnumerable <user> usr = db.users.ToList <user>();
         return(usr);
     }
 }
Exemple #3
0
 public void update(user u)
 {
     using (userDBContext db = new userDBContext())
     {
         user usr = new user();
         usr      = db.users.Find(u.id);
         usr.name = u.name;
         db.SaveChanges();
     }
 }
Exemple #4
0
 public void deleteUser(int id)
 {
     using (userDBContext db = new userDBContext())
     {
         user u = new user();
         u.id = id;
         db.users.Attach(u);
         db.users.Remove(u);
         db.SaveChanges();
     }
 }
Exemple #5
0
 public int addUser(user u)
 {
     using (userDBContext db = new userDBContext())
     {
         if (u.name != null)
         {
             db.users.Add(u);
             return(db.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
 }
Exemple #6
0
 public Repository()
 {
     _db      = new userDBContext();
     entities = _db.Set <T>();
 }