예제 #1
0
 public IEnumerable <User> GetUsers()
 {
     using (var db = new UserManagementDb())
     {
         var result = db.Users.ToList();
         return(result);
     }
 }
예제 #2
0
 public User GetUserById(string userId)
 {
     using (var db = new UserManagementDb())
     {
         var result = db.Users.Where(x => x.Id == userId).FirstOrDefault();
         return(result);
     }
 }
예제 #3
0
 public bool Add(User user)
 {
     using (var db = new UserManagementDb())
     {
         var result = db.Users.Add(user);
         db.SaveChanges();
         return(result != null ? true : false);
     }
 }
예제 #4
0
 public bool Delete(User user)
 {
     using (var db = new UserManagementDb())
     {
         db.Configuration.ValidateOnSaveEnabled = false;
         db.Users.Attach(user);
         db.Users.Remove(user);
         db.SaveChanges();
         db.SaveChanges();
         return(user != null ? true : false);
     }
 }
예제 #5
0
 public bool UpdateUser(User user)
 {
     using (var db = new UserManagementDb())
     {
         var result = db.Users.Where(x => x.Id == user.Id).FirstOrDefault();
         result.Hobbies      = user.Hobbies;
         result.HomeTown     = user.HomeTown;
         result.FullName     = user.FullName;
         result.Description  = user.Description;
         result.Image        = user.Image;
         result.Img          = user.Img;
         result.PersonalBlog = user.PersonalBlog;
         db.SaveChanges();
         return(true);
     }
 }