Esempio n. 1
0
 /// <summary>
 /// Generates records.
 /// </summary>
 /// <param name="amount">Number of records to create.</param>
 private static void GenerateRecords(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         fileCabinetService.CreateRecord(Generator.GenerateRecord());
     }
 }
Esempio n. 2
0
 private static void Create(string parameters)
 {
     object[] newRecordData = UserQuestioning();
     fileCabinetService.CreateRecord(new ObjectParametrsForCreateAndEditRecord(
                                         newRecordData[0].ToString(),
                                         newRecordData[1].ToString(),
                                         (DateTime)newRecordData[2],
                                         (short)newRecordData[3],
                                         (decimal)newRecordData[4],
                                         (char)newRecordData[5]));
     Console.WriteLine($"Record #{fileCabinetService.GetStat()} is created.");
 }
Esempio n. 3
0
        private static void Create(string parameters)
        {
            try
            {
                Console.Write(FirstNameOutput);
                string firstName = ReadInput(StringConverter, FirstNameValidator);

                Console.Write(LastNameOutput);
                string lastName = ReadInput(StringConverter, LastNameValidator);

                Console.Write(SexOutput);
                char sex = ReadInput(CharConverter, SexValidator);

                Console.Write(WeightOutput);
                short weight = ReadInput(ShortConverter, WeightValidator);

                Console.Write(DateOfBirthOutput);
                DateTime dateOfBirth = ReadInput(DateConverter, DateOfBirthValidator);

                Console.Write(BalanceOutput);
                decimal balance = ReadInput(DecimalConverter, BalanceValidator);

                var newRecord = new FileCabinetRecordWithoutID()
                {
                    FirstName   = firstName,
                    LastName    = lastName,
                    Sex         = sex,
                    DateOfBirth = dateOfBirth,
                    Weight      = weight,
                    Balance     = balance,
                };

                Console.WriteLine($"record #{fileCabinetService.CreateRecord(newRecord)} is created.");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(TryAgainOutput);
            }
        }
Esempio n. 4
0
        private static void Create(string parameters)
        {
            var typesConverter = new RecordTypesConverter();

            Console.Write("First name: ");
            string firstName = ReadInput(typesConverter.StringConverter, recordValidator.FirstNameValidator);

            Console.Write("Last name: ");
            string lastName = ReadInput(typesConverter.StringConverter, recordValidator.LastNameValidator);

            Console.Write("Date of birth: ");
            DateTime dateOfBirth = ReadInput(typesConverter.DateTimeConverter, recordValidator.DateOfBirthValidator);

            Console.Write("Age: ");
            short age = ReadInput(typesConverter.ShortConverter, recordValidator.AgeValidator);

            Console.Write("Money: ");
            decimal money = ReadInput(typesConverter.DecimalConverter, recordValidator.MoneyValidator);

            Console.Write("Any letter: ");
            char letter = ReadInput(typesConverter.CharConverter, recordValidator.LetterValidator);

            var record = new FileCabinetRecord()
            {
                FirstName   = firstName,
                LastName    = lastName,
                DateOfBirth = dateOfBirth,
                Age         = age,
                Money       = money,
                Letter      = letter,
            };

            int id = fileCabinetService.CreateRecord(record);

            Console.WriteLine($"Record #{id} is created.");
        }