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(); }
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)); } }
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); }
private void SaveNewPerson() { _personService.AddNewPerson(SelectedPerson); Persons = new ObservableCollection <Person>(_personService.GetPersons()); }