コード例 #1
0
        public async Task <CreateAdminOutput> CreateAdmin(CreateAdminInput input)
        {
            var admin = await _adminManager.CreateAdmin(input.UserName, input.Password, input.Name, input.TenantId);

            admin.EmailAddress = input.EmailAddress;
            admin.Phone        = input.Phone;

            return(new CreateAdminOutput());
        }
コード例 #2
0
        public async Task <CreateAdminOutput> CreateAdmin(CreateAdminInput dto)
        {
            var output = new CreateAdminOutput {
                Result = dto.Result
            };

            if (await this.AccountRpository.ExistedAsync(dto.Model.UserName))
            {
                output.Result.ResultCode = (int)AccountResultCode.UserNameExisted;
                output.Result.Message    = "该用户名存在";
                return(output);
            }
            var account = new TAccount
            {
                Name     = dto.Model.UserName,
                Password = dto.Model.Password,
                Type     = dto.Model.AccountType,
                Emai     = dto.Model.Email,
            };

            account.SetCreator(1);
            account.SetUpdater(1);
            await this.AccountRpository.AddAsync(account);

            var amax = await this.AdminRpository.GetMaxJobNumber();

            var cmax = await this.CustomerRpository.GetMaxJobNumber();

            var admin = new TAdmin
            {
                AccountId = account.Id,
                JobNumber = JobNumberUtils.GetJobNumber(amax, cmax),
            };

            admin.SetCreator(1);
            admin.SetUpdater(1);
            await this.AdminRpository.AddAsync(admin);

            if (!await this.SaveChangesAsync())
            {
                output.Result.Message = "数据保存失败";
                return(output);
            }
            output.Result.ResultCode = (int)ResultCode.Successful;
            return(output);
        }