public Person UpdatePerson(IPersonDto personDto) { if (personDto?.GoogleId == null) { Log.Error("Cannot update person when no resource name provided!"); return(null); } var contactToUpdate = PersonBuilder.Build(personDto); contactToUpdate.ResourceName = personDto.GoogleId.ResourceName; contactToUpdate.ETag = personDto.GoogleId.ETag; var request = new PeopleResource.UpdateContactRequest(CreateService(), contactToUpdate, contactToUpdate.ResourceName) { UpdatePersonFields = new List <string> { "phoneNumbers", "emailAddresses", "names", "birthdays", "addresses" } }; return(ExecuteChecking(request.Execute)); }
public void GivenPerson_WhenDeriving_ThenThereAreNoRequiredRelations() { var builder = new PersonBuilder(this.Session); builder.Build(); Assert.IsFalse(this.Session.Derive().HasErrors); }
public void GivenPerson_WhenDeriving_ThenRequiredRelationsMustExist() { var builder = new PersonBuilder(this.Session); builder.Build(); Assert.False(this.Session.Derive(false).HasErrors); }
public void btn_submit_Clicked() { // NEED TO DO VERIFICATION ON FORM. TRY CATCH ON REQUIRED EMPTY VARIABLES? if (string.IsNullOrEmpty(view.getMiddleName())) { personBuilder .WithNoMiddleName((Prefix)Enum.Parse(typeof(Prefix), view.getTitle()), view.getFirstName(), view.getLastName()); if (string.IsNullOrEmpty(view.getEmergency())) { personBuilder .WithPrimaryContactOnly(view.getPhone()); if (string.IsNullOrEmpty(view.getSecondLine()) && string.IsNullOrEmpty(view.getThirdLine())) { addressBuilder .OneLineAddress(view.getFirstLine(), view.getCity(), view.getCounty(), view.getPostcode()); } else if (string.IsNullOrEmpty(view.getThirdLine())) { addressBuilder .TwoLineAddress(view.getFirstLine(), view.getSecondLine(), view.getCity(), view.getCounty(), view.getPostcode()); } else { addressBuilder .ThreeLineAddress(view.getFirstLine(), view.getSecondLine(), view.getThirdLine(), view.getCity(), view.getCounty(), view.getPostcode()); } } else { personBuilder .WithAllContacts(view.getPhone(), view.getEmergency()); } } else { personBuilder .WithMiddleName((Prefix)Enum.Parse(typeof(Prefix), view.getTitle()), view.getFirstName(), view.getMiddleName(), view.getLastName()); } gp = personBuilder.Build(); address = addressBuilder.Build(); GP practice = new GP(); practice.GPPractice = view.getPracticeName(); MemberDB.InsertGP(gp); AddressDB.InsertAddress(address); GPDB.InsertGP(practice); ConfirmationForm cForm = new ConfirmationForm(); ConfirmationPresenter cPresenter = new ConfirmationPresenter(cForm); cForm.Show(); }
static void ConfigureUser() { PersonBuilder builder = new PersonBuilder(); builder.SetFirstName("Max"); builder.SetLastName("Planck"); Person person = builder.Build(); Console.WriteLine(person); }
public static void Main() { PersonBuilder builder = new PersonBuilder(); builder.Name = "Andrew"; builder.Age = 29; Person person = builder.Build(); Console.WriteLine(person.Name); Console.WriteLine(person.Age); }
public void Create_Valid_Person() { // Arrange var builder = new PersonBuilder(LocalNotification) .WithName("John"); // Act builder.Build(); // Assert Assert.False(LocalNotification.HasNotification()); }
public void PersonBuilder_WhenNumberOfItemsAreLessThanFour_ShouldNotCreatePerson() { var listOfItems = new List <string>() { "Gilberto", "2.330", "2.330" }; var target = new PersonBuilder(_aliasProviderMock.Object); target.Build(listOfItems); }
public void PersonBuilder_WhenRankIsBlank_ShouldNotCreatePerson() { var listOfItems = new List <string>() { "Gilberto", "2.330", "2.330", "" }; var target = new PersonBuilder(_aliasProviderMock.Object); target.Build(listOfItems); }
public data_using_default_person_builder() { _personBuilder = new PersonBuilder(DataContainer); _emailBuilder = new EmailBuilder(DataContainer); _builder = new Builder<MyPerson>() .With(x => { var person = _personBuilder.Build(); var emails = _emailBuilder.WithPerson(person).Build(1, 3).ToArray(); x.Name = person.FullName; x.Emails = emails.Select(e => e.Address); }); }
public void Create_Person_With_Invalid_Description() { // Arrange var builder = new PersonBuilder(LocalNotification) .WithName(null); // Act builder.Build(); // Assert Assert.True(LocalNotification.HasNotification()); var notifications = LocalNotification.GetAll(); Assert.True(notifications.Any(a => a.Message == Person.Error.PersonNameMustHaveValue.ToString())); }
public void PersonBuilder_IfAllParametersAreCorrect_ShouldCreatePerson() { var listOfItems = new List <string>() { "Gilberto", "2.330", "2.330", "2" }; var target = new PersonBuilder(_aliasProviderMock.Object); var personCreated = target.Build(listOfItems); Assert.AreEqual(listOfItems[0], personCreated.Name); Assert.AreEqual(listOfItems[1], personCreated.Frequency.ToString("0.000", CultureInfo.InvariantCulture)); Assert.AreEqual(listOfItems[2], personCreated.CumulativeFrequency.ToString("0.000", CultureInfo.InvariantCulture)); Assert.AreEqual(listOfItems[3], personCreated.Rank.ToString()); }
private async Task <Person> SeedPerson(bool withOrganisation = false) { var builder = new PersonBuilder(true); if (withOrganisation) { builder.WithOrganisation(); } var newPerson = builder.Build(); using (var db = new BookingsDbContext(BookingsDbContextOptions)) { await db.Persons.AddAsync(newPerson); await db.SaveChangesAsync(); } return(newPerson); }
public void Build_Demo() { var builder = new PersonBuilder(); Person defaultPerson = builder.Build(); Person alex = builder.WithFirstName("Alex").Build(); Person darkoAzure = builder. WithFirstName("Darko"). WithLastName("Azure").Build(); Person darkoAzure10 = builder.WithBirthDate(210, 12, 11).Build(); Person alex10 = builder. WithPersonProperties(alex). WithBirthDate(darkoAzure10.BirthDate).Build(); Console.WriteLine(defaultPerson); Console.WriteLine(alex); Console.WriteLine(darkoAzure); Console.WriteLine(darkoAzure10); Console.WriteLine(alex10); }
public Person AddPerson(IPersonDto personDto) { var contactToCreate = PersonBuilder.Build(personDto); return(ExecuteChecking(new PeopleResource.CreateContactRequest(CreateService(), contactToCreate).Execute)); }
public void btn_submit_Clicked() { personBuilder .setMember((Member)Enum.Parse(typeof(Member), view.getMember())) .setGender((Gender)Enum.Parse(typeof(Gender), view.getGender())) .setDOB(view.getDOB()); if (string.IsNullOrEmpty(view.getMiddleName())) { personBuilder .WithNoMiddleName((Prefix)Enum.Parse(typeof(Prefix), view.getTitle()), view.getFirstName(), view.getLastName()); if (string.IsNullOrEmpty(view.getEmergency())) { personBuilder .WithPrimaryContactOnly(view.getPhone()); if (string.IsNullOrEmpty(view.getSecondLine()) && string.IsNullOrEmpty(view.getThirdLine())) { addressBuilder .OneLineAddress(view.getFirstLine(), view.getCity(), view.getCounty(), view.getPostcode()); } else if (string.IsNullOrEmpty(view.getThirdLine())) { addressBuilder .TwoLineAddress(view.getFirstLine(), view.getSecondLine(), view.getCity(), view.getCounty(), view.getPostcode()); } else { addressBuilder .ThreeLineAddress(view.getFirstLine(), view.getSecondLine(), view.getThirdLine(), view.getCity(), view.getCounty(), view.getPostcode()); } } else { personBuilder .WithAllContacts(view.getPhone(), view.getEmergency()); } } else { personBuilder .WithMiddleName((Prefix)Enum.Parse(typeof(Prefix), view.getTitle()), view.getFirstName(), view.getMiddleName(), view.getLastName()); } member = personBuilder.Build(); MemberDB.InsertMember(member); address = addressBuilder.Build(); AddressDB.InsertAddress(address); if (view.getMember() == "Patient") { GPInformationForm gpForm = new GPInformationForm(); GPInformationPresenter gpPresenter = new GPInformationPresenter(gpForm); gpForm.Show(); } else { ConfirmationForm cForm = new ConfirmationForm(); ConfirmationPresenter cPresenter = new ConfirmationPresenter(cForm); cForm.Show(); } }