/// <summary>Validates the date.</summary>
        /// <param name="date">The date.</param>
        /// <returns>Tuple with two elements: first - is date correct, second - message if it is not correct, empty string if it is not.</returns>
        public static Tuple <bool, string> ValidateDate(DateTime date)
        {
            try
            {
                fileCabinetService.GetValidator().Validate("1234", "1234", 123, 'a', 1, date);
            }
            catch (ArgumentException e)
            {
                return(new Tuple <bool, string>(false, e.Message));
            }

            return(new Tuple <bool, string>(true, string.Empty));
        }
Пример #2
0
        /// <summary>
        /// Gathers information about a record.
        /// </summary>
        /// <param name="service">File cabinet service.</param>
        /// <exception cref="ArgumentNullException">Throws when service is null.</exception>
        /// <returns>Record data.</returns>
        public static DataRecord CollectRecordData(IFileCabinetService service)
        {
            if (service is null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            DataRecord       dataRecord = new DataRecord();
            IRecordValidator validator  = service.GetValidator();

            Console.Write("First name: ");
            dataRecord.FirstName = ReadInput(Converter.StringConverter);

            Console.Write("Last Name: ");
            dataRecord.LastName = ReadInput(Converter.StringConverter);

            Console.Write("Date of birth: ");
            dataRecord.DateOfBirth = ReadInput(Converter.DateConverter);

            Console.Write("Access: ");
            dataRecord.Access = ReadInput(Converter.CharConverted);

            Console.Write("Salary: ");
            dataRecord.Salary = ReadInput(Converter.DecimalConverted);

            return(dataRecord);
        }