예제 #1
0
        static void NewPerson()
        {
            int    option    = 2;
            string firstName = "";
            string lastName  = "";
            string birthday  = "";

            while (option == 2)
            {
                firstName = ReadString("Digite o primeiro nome da pessoa que deseja adicionar: ");
                lastName  = ReadString("Digite o sobrenome da pessoa que deseja adicionar: ");
                birthday  = ReadString("Digite a data de aniversário no formato dd/MM/yyyy: ");

                while (ApplicationUtils.checkDate(birthday) == false)
                {
                    Console.WriteLine("Data inválida.");
                    birthday = ReadString("Digite a data de aniversário no formato dd/MM/yyyy: ");
                }

                Console.WriteLine("Os dados abaixo estão corretos?");
                Console.WriteLine($"Nome: {firstName} {lastName}");
                Console.WriteLine($"Data do aniversário: {birthday}");
                option = int.Parse(ReadString("1 - Sim  /  2 - Não: "));

                Console.Clear();
            }

            DateTime birthdayConverted = Convert.ToDateTime(birthday);

            var newPerson = PersonService.AddNewPerson(firstName, lastName, birthdayConverted);

            Console.WriteLine($"{newPerson}\n");

            MainMenu();
        }
예제 #2
0
        public async Task <ActionResult <Person> > PostPerson(Person person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                await _personService.AddNewPerson(person);

                return(Ok(person));
            }
            catch (Exception exception)
            {
                return(BadRequest(exception));
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: jwonagel/IMS
        private static void CreatePerson()
        {
            Console.WriteLine("Name");
            var name = Console.ReadLine();

            Console.WriteLine("Vorname:");
            var firstName = Console.ReadLine();

            Console.WriteLine("Strasse:");
            var street = Console.ReadLine();

            Console.WriteLine("Hausnummer:");
            var houseNumber = Console.ReadLine();

            Console.WriteLine("Zip:");
            var zip = Console.ReadLine();

            Console.WriteLine("Ort:");
            var city = Console.ReadLine();

            var person = new Person()
            {
                FirstName = firstName,
                LastName  = name,
                Address   = new Address()
                {
                    Street      = street,
                    HouseNumber = houseNumber,
                    Zip         = zip,
                    City        = city
                }
            };

            var service = new PersonService();

            service.AddNewPerson(person);
        }
예제 #4
0
 private void SaveNewPerson()
 {
     _personService.AddNewPerson(SelectedPerson);
     Persons = new ObservableCollection <Person>(_personService.GetPersons());
 }