コード例 #1
0
        public GatherContactInfoResponse GatherContactInfo([FromBody] GetContactInfoDTO getContactInfo)
        {
            if (getContactInfo is null)
            {
                throw new ArgumentNullException(nameof(getContactInfo));
            }

            var request = new GatherContactInfoRequest(
                getContactInfo.Name,
                getContactInfo.Address,
                getContactInfo.DateOfBirth,
                getContactInfo.NationalInsuranceNumber);

            var requestHandler = new GatherContactInfoInteractor(
                this._creditScoreService,
                this._customerDatabase);

            return(requestHandler.Handle(request));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mleybsage/standard-repo
        /// <summary>
        /// Main application entry point.
        /// </summary>
        /// <param name="args">Arguments passed into the application at runtime.</param>
        public static void Main(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentException("args cannot be null");
            }

            var getContactInteractor = new GatherContactInfoInteractor(new MockCreditScoreService(), new CustomerDatabaseInMemoryImpl());

            Console.WriteLine("Name?");
            var name = Console.ReadLine();

            Console.WriteLine("Address?");
            var address = Console.ReadLine();

            Console.WriteLine("Date of birth (yyyy-MM-dd)?");
            var dateOfBirth = DateTime.Parse(Console.ReadLine());

            Console.WriteLine("NI Number?");
            var niNumber = Console.ReadLine();

            var getContactResponse = getContactInteractor.Handle(new GatherContactInfoRequest(name, address, dateOfBirth, niNumber));

            if (getContactResponse.HasError)
            {
                foreach (var error in getContactResponse.Errors)
                {
                    Console.WriteLine(error);
                }
            }
            else
            {
                var result = getContactResponse.IsAcceptedForLoan ? "accepted" : "rejected";

                Console.WriteLine($"Credit score is {getContactResponse.CreditScore} so customer has been {result}");
            }

            Console.WriteLine("Press any key to close");
            Console.ReadKey();
        }