public static PersonAdded Add(string name, string lastname, DateTime birthday) { try { if (name == "") { throw new Exception("Name is empty"); } if (lastname == "") { throw new Exception("Lastame is empty"); } Person person = new Person(name, lastname, birthday); bool addPersonResult = PersonRepositoryWrapper.AddPerson(person); PersonAdded personStatus = new PersonAdded { Registered = addPersonResult }; personStatus.Message = personStatus.Registered ? "Person Registered" : "Person not Registered"; return(personStatus); } catch (Exception exception) { return(new PersonAdded { Registered = false, Message = exception.Message }); } }
public static PersonAdded Add(string name, string lastname, DateTime birthday) { try { if (name == "") { throw new Exception("Name is empty"); } if (lastname == "") { throw new Exception("Lastame is empty"); } Person person = new Person(0, name, lastname, birthday); personRepository.AddPerson(person); PersonAdded personStatus = new PersonAdded { Registered = true, Message = "Person Registered" }; return(personStatus); } catch (Exception exception) { return(new PersonAdded { Registered = false, Message = exception.Message }); } }
public static void NewPerson() { string firstName = ReadString("Digite o nome: ");; string lastName = ReadString("Digite o sobrenome: "); string birthday = ReadString("Digite o aniversário no formato (MM/dd/yyyy): "); PersonAdded addNewPersonResult = PeopleService.AddNewPerson(firstName, lastName, birthday); EndMethod(addNewPersonResult.Message); }
public async void AddItems() { count++; var person = new Person { Name = ItemEntry, Id = count }; await _sqlCrud.AddItem(person); //Uncomment if you want to test with message center, But remember to comment out the event handler! //MessagingCenter.Send(this, "AddedPerson", person); PersonAdded?.Invoke(this, person); await _pageService.PopAsync(); }
public void AddPerson(string name) { PersonAdded?.Invoke(name); }