예제 #1
0
 public void UpdateUser(User user)
 {
     using (var context = new GiaikhatNgocMaiEntities())
     {
         var dbUser = context.Users.SingleOrDefault(u => u.Id == user.Id);
         if (dbUser == null) throw new NullReferenceException("Can not found user " + user.UserName);
         context.Entry(user).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #2
0
 public int CreateUser(User user)
 {
     using (var context = new GiaikhatNgocMaiEntities())
     {
         context.Users.Add(user);
         context.SaveChanges();
         return user.Id;
     }
 }