예제 #1
0
        /// <summary>
        /// Метод создания базовых реквизитов
        /// </summary>
        /// <param name="lastName">фамилия</param>
        /// <param name="firstName">имя</param>
        /// <param name="middleName">отчество</param>
        /// <param name="series">серия</param>
        /// <param name="number">номер</param>
        /// <param name="address">адрес</param>
        /// <param name="phoneNumber">номер телефона</param>
        /// <param name="email">эмейл</param>
        /// <returns>паспортные данные, контактные данные</returns>
        private static (Passport passport, Contact contact) CreateBaseRequisites(string lastName, string firstName, string middleName,
                                                                                 string series, string number,
                                                                                 string address,
                                                                                 string phoneNumber, string email)
        {
            //Паспортные данные
            var fullName        = FullNameFactory.CreateFullName(lastName, firstName, middleName);
            var seriesAndNumber = SeriesAndNumberFactory.CreateSeriesAndNumber(series, number);
            var passport        = PassportFactory.CreatePassport(fullName, seriesAndNumber, address);

            //Контактные данные
            var phone   = PhoneNumberFactory.CreateNumber(phoneNumber);
            var contact = ContactFactory.CreateContact(phone, email);

            return(passport, contact);
        }
예제 #2
0
        /// <summary>
        /// Метод создания базовых реквизитов
        /// </summary>
        /// <param name="lastName">фамилия</param>
        /// <param name="firstName">имя</param>
        /// <param name="middleName">отчество</param>
        /// <param name="series">серия</param>
        /// <param name="number">номер</param>
        /// <param name="address">адрес</param>
        /// <param name="phoneNumber">номер телефона</param>
        /// <param name="email">эмейл</param>
        /// <param name="cardName">наименование карты</param>
        /// <param name="accountType">тип аккаунта</param>
        /// <returns>паспортные данные, контактные данные, аккаунт</returns>
        private static (Passport passport, Contact contact, Account account) CreateBaseRequisites(string lastName, string firstName, string middleName,
                                                                                                  string series, string number,
                                                                                                  string address,
                                                                                                  string phoneNumber, string email,
                                                                                                  string cardName, AccountType accountType)
        {
            //Паспортные данные
            var fullName        = FullNameFactory.CreateFullName(lastName, firstName, middleName);
            var seriesAndNumber = SeriesAndNumberFactory.CreateSeriesAndNumber(series, number);
            var passport        = PassportFactory.CreatePassport(fullName, seriesAndNumber, address);

            //Контактные данные
            var phone   = PhoneNumberFactory.CreateNumber(phoneNumber);
            var contact = ContactFactory.CreateContact(phone, email);

            //Данные аккаунта
            var card    = SimpleCardFactory.CreateCard(cardName, default);
            var deposit = new NullDeposit();
            var account = SimpleAccountFactory.CreateAccount(accountType, card, deposit);

            return(passport, contact, account);
        }
예제 #3
0
        /// <summary>
        /// Метод заполнения репозитория клиентами
        /// </summary>
        /// <param name="dbContext">контекст данных</param>
        /// <param name="quantity">кол-во клиентов</param>
        private static void FillRepository(AppDbContext dbContext, int quantity)
        {
            Parallel.For(1, quantity + 1, (i) =>
            {
                lock (locker)
                {
                    Client client = null;

                    decimal cardBalance    = random.Next(1, 10) * 10000;
                    decimal depositBalance = random.Next(1, 10) * 10000;
                    bool capitalization    = Convert.ToBoolean(random.Next(2));

                    //Паспортные данные
                    var passport = PassportFactory.CreatePassport(
                        FullNameFactory.CreateFullName(Gender.Female),
                        SeriesAndNumberFactory.CreateSeriesAndNumber(),
                        $"Адрес_{i}");

                    //Контактные данные
                    var contact = ContactFactory.CreateContact(PhoneNumberFactory.CreateNumber(), $"Client@Email_{i}.ru");

                    switch (random.Next(Enum.GetNames(typeof(ClientType)).Length))
                    {
                    case (int)ClientType.Individual:

                        //Данные аккаунта
                        var card    = IndividualsCardFactories[random.Next(IndividualsCardFactories.Length)].CreateCard(cardBalance);
                        var deposit = random.Next(2) == 0 ?
                                      new DefaultDepositFactory().CreateDeposit(depositBalance, capitalization, ClientType.Individual) :
                                      new NullDeposit();

                        var individualAccount = AccountFactories[random.Next(AccountFactories.Length)].CreateAccount(card, deposit);

                        //Создание физ. лица
                        client = IndividualFactory.CreateIndividual(passport, contact, individualAccount);
                        break;

                    case (int)ClientType.Entity:

                        //Данные аккаунта
                        card    = EntitiesCardFactories[random.Next(EntitiesCardFactories.Length)].CreateCard(cardBalance);
                        deposit = random.Next(2) == 0 ?
                                  new DefaultDepositFactory().CreateDeposit(depositBalance, capitalization, ClientType.Entity) :
                                  new NullDeposit();

                        var entityAccount = AccountFactories[random.Next(AccountFactories.Length)].CreateAccount(card, deposit);

                        //Данные компании
                        var company = CompanyFactory.CreateCompany($"Компания_{i}", $"http:\\Company.Website_{i}.ru");

                        //Создание юр.лица
                        client = EntityFactory.CreateEntity(passport, contact, entityAccount, company);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    ProcessingCountEvent?.Invoke(Count++);
                    dbContext.Add(client);
                }
            });

            dbContext.SaveChanges();
        }