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; } }
partial void DeleteUser_Role(User_Role instance);
partial void UpdateUser_Role(User_Role instance);
partial void InsertUser_Role(User_Role instance);
private void detach_User_Roles(User_Role entity) { this.SendPropertyChanging(); entity.Role = null; }
private void attach_User_Roles(User_Role entity) { this.SendPropertyChanging(); entity.Role = this; }