private void button_UpdateAccount_Click(object sender, EventArgs e)
        {
            string UserName     = textBox_UserName.Text;
            string Password     = textBox_Password.Text;
            string NameDisplay  = textBox_DisplayName.Text;
            bool   checkAccount = AccountDAO.Instance.CheckExists(textBox_UserName.Text);

            if (checkAccount)
            {
                IAccountBuilder account = new AccountBuilder().SetUserName(UserName).SetPassword(Password).SetDisplayName(NameDisplay);
                AccountDAO.Instance.Update(account.Build());
                textBox_UserName.Clear();
                textBox_Password.Clear();
                textBox_DisplayName.Clear();
                LoadListAccount();
                MessageBox.Show("Sửa tài khoản thành công", "Thông báo");
            }
            else if (string.IsNullOrEmpty(textBox_UserName.Text))
            {
                MessageBox.Show("Hãy chọn tài khoản mà bạn muốn sửa", "Thông Báo");
            }
            else
            {
                MessageBox.Show("Tài khoản bạn muốn sửa không tồn tại", "Thông Báo");
            }
        }
示例#2
0
        public Account ToSDKAccount()
        {
            if (sdkAccount != null)
            {
                return(sdkAccount);
            }
            else if (apiAccount != null)
            {
                AccountBuilder builder = AccountBuilder.NewAccount()
                                         .WithCompany(new CompanyConverter(apiAccount.Company).ToSDKCompany())
                                         .CreatedOn(apiAccount.Created)
                                         .UpdatedOn(apiAccount.Updated)
                                         .WithData(apiAccount.Data)
                                         .WithId(apiAccount.Id)
                                         .WithLogoUrl(apiAccount.LogoUrl)
                                         .WithOwner(apiAccount.Owner)
                                         .WithName(apiAccount.Name)
                                         .WithAccountProviders(new AccountProvidersConverter(apiAccount.Providers).ToSDKAccountProviders());
                foreach (API.CustomField field in apiAccount.CustomFields)
                {
                    builder.WithCustomField(new CustomFieldConverter(field).ToSDKCustomField());
                }

                foreach (API.License license in apiAccount.Licenses)
                {
                    builder.WithLicense(new LicenseConverter(license).ToSDKLicense());
                }

                return(builder.Build());
            }
            else
            {
                return(null);
            }
        }
 private void button_AddAccount_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(textBox_UserName.Text) || string.IsNullOrEmpty(textBox_Password.Text) || string.IsNullOrEmpty(textBox_DisplayName.Text))
         {
             MessageBox.Show("Hãy điền đầy đủ thông tin tài khoản bạn muốn thêm", "Thông báo");
         }
         else
         {
             string          UserName    = textBox_UserName.Text;
             string          Password    = textBox_Password.Text;
             string          NameDisplay = textBox_DisplayName.Text;
             int             Type        = int.Parse(textBox_Type.Text);
             IAccountBuilder account     = new AccountBuilder().SetUserName(UserName).SetPassword(Password).SetDisplayName(NameDisplay).SetTypeAccount(Type);
             AccountDAO.Instance.Create(account.Build());
             textBox_UserName.Clear();
             textBox_Password.Clear();
             textBox_DisplayName.Clear();
             LoadListAccount();
             MessageBox.Show("Thêm tài khoản thành công", "Thông báo");
         }
     }
     catch
     {
         MessageBox.Show("Tên tài khoản đã tồn tại. Hãy thử lại", "Thông Báo");
     }
 }
示例#4
0
        public async Task Setup()
        {
            var account = AccountBuilder.Build();

            BookBuilder.WithLibrary(LibraryId).IsPublic().AddToFavorites(AccountId).Build(25);

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books?pageNumber=1&pageSize=10&favorite=true");

            _assert = new PagingAssert <BookView>(_response);
        }
示例#5
0
        public async Task Setup()
        {
            var account = AccountBuilder.Build();

            _book = BookBuilder.WithLibrary(LibraryId).WithPages(20).WithStatus(_status, 15).Build();

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_book.Id}/pages?pageSize=10&pageNumber=1&status={_status.ToDescription()}");

            _assert = new PagingAssert <BookPageView>(_response);
        }
        ///<summary>Build new app instance</summary>
        ///<param name="developerSecret">Developer secret seed</param>
        ///<param name="address">User public key</param>
        ///<returns>Promise returns new app instance</returns>
        async public Task <App> Build(string developerSecret, string address)
        {
            var developerKeypair = Stellar.KeyPair.FromSecretSeed(developerSecret);
            var developerAccount = await AccountBuilder.Build(developerKeypair);

            var userKeypair = Stellar.KeyPair.FromAccountId(address);
            var userAccount = await AccountBuilder.Build(userKeypair);

            return(new App(developerAccount, userAccount));
        }
        public async Task Setup()
        {
            var account = AccountBuilder.Build();

            _book = BookBuilder.WithLibrary(LibraryId).WithPages(20).AssignPagesTo(account.Id, 15).Build();

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_book.Id}/pages?pageSize=10&pageNumber=1&assignmentFilter=assigned");

            _assert = new PagingAssert <BookPageView>(_response);
        }
示例#8
0
        public AccountModel Create(AccountModel accountModel, IConfiguration configuration)
        {
            accountBusinessRules.CreateCheck(accountModel, unitOfWork.Account);
            accountModel.Password = GeneratePassword.CreateRandomPassword();
            unitOfWork.Account.Insert(accountBuilder.Build(accountModel));
            unitOfWork.Save();

            SendCreateAccountEmail(accountModel, configuration);

            return(GetAccountByUsername(accountModel.Username));
        }
示例#9
0
        public TestBase(Role?role = null, bool periodicalsEnabled = false, bool createLibrary = true)
        {
            _periodicalsEnabled = periodicalsEnabled;
            _role = role;

            var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var projectDir  = Directory.GetCurrentDirectory();
            var configPath  = Path.Combine(projectDir, "appsettings.json");

            _factory = new WebApplicationFactory <Startup>()
                       .WithWebHostBuilder(builder =>
            {
                builder.ConfigureAppConfiguration((context, conf) =>
                {
                    conf.AddJsonFile(configPath);

                    if (!string.IsNullOrWhiteSpace(environment))
                    {
                        conf.AddJsonFile(Path.Combine(projectDir, $"appsettings.json"), true);
                        //conf.AddJsonFile(Path.Combine(projectDir, $"appsettings.{environment}.json"), true);
                    }
                });
                builder.ConfigureTestServices(services => ConfigureServices(services));
            });

            var settings = Services.GetService <Settings>();

            AccountBuilder = _factory.Services.GetService <AccountDataBuilder>();

            if (role.HasValue)
            {
                AccountBuilder = AccountBuilder.As(_role.Value).Verified();
                _account       = AccountBuilder.Build();
            }

            if (createLibrary)
            {
                var builder = LibraryBuilder.WithPeriodicalsEnabled(_periodicalsEnabled);
                if (_account != null && role.HasValue)
                {
                    builder.AssignToUser(AccountId, _role.Value);
                }
                Library = builder.Build();
            }

            Client = _factory.CreateClient();

            if (_account != null)
            {
                var token = TokenBuilder.GenerateToken(settings, _account.Id);
                Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
            }
        }
示例#10
0
        public void TestMethodToCheckIfAccountBuilderPasses()
        {
            AccountBuilder accountBuilder = new AccountBuilder()
                                            .SetAccountNumber(111111234)
                                            .SetCurrentBalance(10000)
                                            .SetTotalBalance(2000000)
                                            .SetInterestRate(15)
                                            .SetType("LoanAccount");

            Assert.IsTrue(accountBuilder.Build() is ILoanEntity);

            accountBuilder = new AccountBuilder()
                             .SetType("SavingsAccount")
                             .SetCurrentBalance(10000)
                             .SetInterestRate(14);
            Assert.IsTrue(accountBuilder.Build() is IInterestEntity);
        }
示例#11
0
        public async Task <(Account account, string errorMessage)> CreateAccountAsync(Action <IAccountBuilder> builderOptions)
        {
            var builder = new AccountBuilder();

            builderOptions(builder);
            Account newAccount = builder.Build();

            if (!await Repository.Set().AnyAsync(AccountExist(newAccount)))
            {
                await Repository.Set().AddAsync(newAccount);

                await Repository.SaveChangesAsync();

                return(newAccount, errorMessage : string.Empty);
            }

            return(null, "Such account already exists!");
        }
示例#12
0
        public async Task Setup()
        {
            _secondAccountId = AccountBuilder.Build().Id;
            var book = BookBuilder.WithLibrary(LibraryId).WithPages(3, true).Build();

            _page = BookBuilder.GetPages(book.Id).PickRandom();

            var assignment = new
            {
                Status    = EditingStatus.Typed,
                AccountId = _secondAccountId
            };

            _exptectedPage = new BookPageDto(_page)
            {
                Status    = assignment.Status,
                AccountId = assignment.AccountId
            };

            _response = await Client.PostObject($"/libraries/{LibraryId}/books/{book.Id}/pages/{_page.SequenceNumber}/assign", assignment);

            _assert = BookPageAssert.FromResponse(_response, LibraryId);
        }
示例#13
0
        public void withSpecifiedValues()
        {
            AccountBuilder accountBuilder = AccountBuilder.NewAccount()
                                            .WithName(ACC_NAME)
                                            .WithId(ACC_ID)
                                            .WithOwner(ACC_OWNER)
                                            .WithLogoUrl(ACC_LOGOURL)
                                            .WithData(ACC_DATA)
                                            .WithCompany(CompanyBuilder.NewCompany(ACC_CO_NAME)
                                                         .WithAddress(AddressBuilder.NewAddress()
                                                                      .WithAddress1(ACC_CO_ADDR_ADDR1)
                                                                      .WithAddress2(ACC_CO_ADDR_ADDR2)
                                                                      .WithCity(ACC_CO_ADDR_CITY)
                                                                      .WithCountry(ACC_CO_ADDR_COUNTRY)
                                                                      .WithState(ACC_CO_ADDR_STATE)
                                                                      .WithZipCode(ACC_CO_ADDR_ZIP).Build())
                                                         .WithId(ACC_CO_ID)
                                                         .WithData(ACC_CO_DATA)
                                                         .Build())
                                            .WithCustomField(CustomFieldBuilder.CustomFieldWithId(ACC_FIELD_ID)
                                                             .WithDefaultValue(ACC_FIELD_DEF_VLE)
                                                             .IsRequired(ACC_FIELD_IS_REQUIRED)
                                                             .WithTranslation(TranslationBuilder.NewTranslation(ACC_FIELD_TRANSL_LANG).Build())
                                                             .Build())
                                            .WithLicense(LicenseBuilder.NewLicense()
                                                         .CreatedOn(ACC_LIC_CREATED)
                                                         .WithPaidUntil(ACC_LIC_PAIDUNTIL)
                                                         .WithStatus(ACC_LIC_STATUS)
                                                         .WithTransaction(ACC_LIC_TRANS_CREATED,
                                                                          CreditCardBuilder.NewCreditCard()
                                                                          .WithCvv(ACC_LIC_TRANS_CC_CVV)
                                                                          .WithName(ACC_LIC_TRANS_CC_NAME)
                                                                          .WithNumber(ACC_LIC_TRANS_CC_NUM)
                                                                          .WithType(ACC_LIC_TRANS_CC_TYPE)
                                                                          .WithExpiration(ACC_LIC_TRANS_CC_EXP_MONTH, ACC_LIC_TRANS_CC_EXP_YEAR)
                                                                          .Build(),
                                                                          PriceBuilder.NewPrice()
                                                                          .WithAmount(ACC_LIC_TRANS_PRICE_AMOUNT)
                                                                          .WithCurrency(ACC_LIC_TRANS_PRICE_CURR_ID, ACC_LIC_TRANS_PRICE_CURR_NAME,
                                                                                        ACC_LIC_TRANS_PRICE_CURR_DATA)
                                                                          .Build())
                                                         .WithPlan(PlanBuilder.NewPlan(ACC_LIC_PLAN_ID)
                                                                   .WithId(ACC_LIC_PLAN_NAME)
                                                                   .WithContract(ACC_LIC_PLAN_CONTRACT)
                                                                   .WithDescription(ACC_LIC_PLAN_DES)
                                                                   .WithGroup(ACC_LIC_PLAN_GRP)
                                                                   .WithCycle(ACC_LIC_PLAN_CYC)
                                                                   .WithOriginal(ACC_LIC_PLAN_ORI)
                                                                   .WithData(ACC_LIC_PLAN_DATA)
                                                                   .WithFreeCycles(ACC_LIC_PLAN_CYC_COUNT, ACC_LIC_PLAN_CYC_CYCLE)
                                                                   .WithQuota(ACC_LIC_PLAN_QUOTA_CYCLE, ACC_LIC_PLAN_QUOTA_LIMIT, ACC_LIC_PLAN_QUOTA_SCOPE,
                                                                              ACC_LIC_PLAN_QUOTA_TARGET)
                                                                   .WithFeatures(ACC_LIC_PLAN_FEAT)
                                                                   .WithPrice(PriceBuilder.NewPrice()
                                                                              .WithAmount(ACC_LIC_PLAN_PRICE_AMOUNT)
                                                                              .WithCurrency(ACC_LIC_PLAN_PRICE_CURR_ID, ACC_LIC_PLAN_PRICE_CURR_NAME,
                                                                                            ACC_LIC_PLAN_PRICE_CURR_DATA)
                                                                              .Build())
                                                                   .Build())
                                                         .Build())
                                            .WithAccountProviders(new List <Provider>()
            {
                ProviderBuilder.NewProvider(ACC_PROV_DOC_NAME)
                .WithData(ACC_PROV_DOC_DATA)
                .WithId(ACC_PROV_DOC_ID)
                .WithProvides(ACC_PROV_DOC_NAME)
                .Build()
            }, new List <Provider>()
            {
                ProviderBuilder.NewProvider(ACC_PROV_USR_NAME)
                .WithData(ACC_PROV_USR_DATA)
                .WithId(ACC_PROV_USR_ID)
                .WithProvides(ACC_PROV_USR_PROVIDES)
                .Build()
            });

            Account account = accountBuilder.Build();

            Assert.AreEqual(ACC_NAME, account.Name);
            Assert.AreEqual(ACC_CO_ID, account.Company.Id);
            Assert.AreEqual(ACC_CO_ADDR_ADDR1, account.Company.Address.Address1);

            Assert.AreEqual(1, account.CustomFields.Count);
            Assert.AreEqual(ACC_FIELD_DEF_VLE, account.CustomFields[0].Value);
            Assert.AreEqual(1, account.CustomFields[0].Translations.Count);
            Assert.AreEqual(ACC_FIELD_TRANSL_LANG, account.CustomFields[0].Translations[0].Language);

            Assert.AreEqual(1, account.Licenses.Count);
            Assert.AreEqual(ACC_LIC_STATUS, account.Licenses[0].Status);
            Assert.AreEqual(1, account.Licenses[0].Transactions.Count);
            Assert.AreEqual(ACC_LIC_TRANS_CC_NUM, account.Licenses[0].Transactions[0].CreditCard.Number);
            Assert.AreEqual(ACC_LIC_TRANS_PRICE_AMOUNT, account.Licenses[0].Transactions[0].Price.Amount);
            Assert.AreEqual(ACC_LIC_PLAN_CONTRACT, account.Licenses[0].Plan.Contract);
            Assert.AreEqual(ACC_LIC_PLAN_PRICE_AMOUNT, account.Licenses[0].Plan.Price.Amount);

            Assert.AreEqual(1, account.Providers.Documents.Count);
            Assert.AreEqual(ACC_PROV_DOC_NAME, account.Providers.Documents[0].Name);
            Assert.AreEqual(1, account.Providers.Users.Count);
            Assert.AreEqual(ACC_PROV_USR_NAME, account.Providers.Users[0].Name);
        }