예제 #1
0
        public bool RegisterUser(string name, string password, int userId)
        {
            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
            {
                _logger.Info("RegisterUser ArgumentNullException");
                throw new ArgumentNullException();
            }

            try
            {
                var userRepository = ContainerService.Instance.Resolve<IRepository<User>>();
                var user = userRepository.FindOne(u => u.Id == userId);

                user.Name = name;
                user.Password = password;

                userRepository.SaveAll();

                var userRoleRepository = ContainerService.Instance.Resolve<IRepository<User_Role>>();

                var userRole = new User_Role
                                         {
                                             Id = userRoleRepository.FindAll().Count() + 1,
                                             UserId = user.Id,
                                             RoleId = 0
                                         };
                userRoleRepository.Add(userRole);
                userRoleRepository.SaveAll();
                return true;
            }
            catch (Exception ex)
            {
                _logger.Error("Register user", ex);
                return false;
            }
        }
예제 #2
0
	partial void DeleteUser_Role(User_Role instance);
예제 #3
0
	partial void UpdateUser_Role(User_Role instance);
예제 #4
0
	partial void InsertUser_Role(User_Role instance);
예제 #5
0
		private void detach_User_Roles(User_Role entity)
		{
			this.SendPropertyChanging();
			entity.Role = null;
		}
예제 #6
0
		private void attach_User_Roles(User_Role entity)
		{
			this.SendPropertyChanging();
			entity.Role = this;
		}