コード例 #1
0
        public void Create(CreateRoleUICommand command)
        {
            if (_systemRoleRepository.GetAll(x => x.Name == command.Name && !x.IsDeleted).Any())
            {
                throw new DomainException(ErrorMessage.RoleNameIsExist);
            }
            var systemRole = SystemRole.Create(command.Name, command.Description, new Guid(), _timeSource.LocalNow());

            using (var unitOfWork = _unitOfWorkFactory.GetCurrentUnitOfWork())
            {
                _systemRoleRepository.Add(systemRole);
                unitOfWork.Commit();
            }
        }
コード例 #2
0
        protected override void Seed(BackgroundDbContext context)
        {
            var migrationCreateDate = new DateTime(2019, 4, 24);
            //Role

            var manager = SystemRole.Create("管理人员", "系统管理员", UserIdProvider.Admin,
                                            migrationCreateDate);

            manager.ForceId(RoleIdProvider.Manager);
            context.SystemRoleContext.AddOrUpdate(manager);

            //用户
            if (!context.SystemUserContext.Any(x => x.Email == "*****@*****.**"))
            {
                var user = SystemUser.Create("Admin", "*****@*****.**", "Password1", RoleIdProvider.Manager,
                                             UserStatus.Enable, migrationCreateDate);
                user.ForceId(UserIdProvider.Admin);
                context.SystemUserContext.AddOrUpdate(user);
            }
        }