コード例 #1
0
 public User GetByUserName(string userName)
 {
     using (var db = new DbDataContext())
     {
         return db.Users.FirstOrDefault(x => x.UserName == userName);
     }
 }
コード例 #2
0
 public User GetById(Guid id)
 {
     using (var db = new DbDataContext())
     {
         return db.Users.FirstOrDefault(x => x.UserId == id);
     }
 }
コード例 #3
0
 public IEnumerable<User> GetUsers()
 {
     using (var db = new DbDataContext())
     {
         var users = db.Users;
         return users;
     }
 }
コード例 #4
0
 public void Remove(User user)
 {
     using (var db = new DbDataContext())
     {
         var _user = db.Users.FirstOrDefault(x => x.UserId == user.UserId);
         if (_user != null)
         {
             db.Users.DeleteOnSubmit(_user);
             db.SubmitChanges();
         }
     }
 }
コード例 #5
0
        public User Create(User user)
        {
            using (var db = new DbDataContext())
            {
                if (user != null)
                {
                    db.Users.InsertOnSubmit(user);
                    db.SubmitChanges();
                }
            }

            return user;
        }
コード例 #6
0
 public void Update(User user)
 {
     using (var db = new DbDataContext())
     {
         var _user = db.Users.FirstOrDefault(x => x.UserId == user.UserId);
         if (user != null)
         {
             _user.Password = user.Password;
             _user.UserName = user.UserName;
             _user.GmailUser = user.GmailUser;
             _user.GmailPassword = user.GmailPassword;
             _user.CreateDate = user.CreateDate;
             db.SubmitChanges();
         }
     }
 }
コード例 #7
0
        private void SetMailRepositoryDependencies(IUnityContainer container)
        {
            if (User != null)
            {
                using (var db = new DbDataContext())
                {
                    var user = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name);

                    if (user != null)
                    {
                        container.RegisterType<IMailRepository, MailRepository>(new ContainerControlledLifetimeManager())
                            .RegisterInstance(new MailRepository(user.GmailUser, user.GmailPassword));
                    }
                }
            }
        }