コード例 #1
0
        private void ExecutePersonCreation()
        {
            WriteLine("\n\tYou have selected the option for creating a person.");
            WriteLine("\t\t* The maximum length of the person's name is 128.");

            var validators = new Validators();

            Write("\n\n\tEnter the person group for which you would like to add the person to: ");
            string personGroupId = ReadLine();

            validators.PersonGroup(personGroupId);

            Write("\n\n\tEnter the name of the person that you would like to add: ");
            string personName = ReadLine();

            validators.PersonName(personName);
            var dto = new PersonDto {
                Name = personName
            };

            _taskList.Add(Task.Factory.StartNew(() =>
            {
                try
                {
                    var result = _personLogic.Create(personGroupId, dto);
                    WriteLine("\t" + result.Message);

                    var person = (PersonDto)result.Data;

                    if (person != null)
                    {
                        WriteLine("\tPerson ID: " + person.PersonId);
                    }
                }

                catch (Exception exception)
                {
                    WriteLine($"\n\tError Message: { exception.Message }");
                    WriteLine($"\n\tInner Exception: { exception.InnerException }");
                    WriteLine($"\n\tStackTrace: { exception.StackTrace }");
                    ReadLine();
                }
            }));
        }