예제 #1
0
        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));
        }
예제 #2
0
파일: PersonTests.cs 프로젝트: Allors/demo
        public void GivenPerson_WhenDeriving_ThenThereAreNoRequiredRelations()
        {
            var builder = new PersonBuilder(this.Session);
            builder.Build();

            Assert.IsFalse(this.Session.Derive().HasErrors);
        }
예제 #3
0
        public void GivenPerson_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var builder = new PersonBuilder(this.Session);

            builder.Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
예제 #4
0
        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();
        }
예제 #5
0
        static void ConfigureUser()
        {
            PersonBuilder builder = new PersonBuilder();

            builder.SetFirstName("Max");
            builder.SetLastName("Planck");

            Person person = builder.Build();

            Console.WriteLine(person);
        }
예제 #6
0
        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);
        }
예제 #7
0
        public void Create_Valid_Person()
        {
            // Arrange
            var builder = new PersonBuilder(LocalNotification)
                          .WithName("John");

            // Act
            builder.Build();

            // Assert
            Assert.False(LocalNotification.HasNotification());
        }
예제 #8
0
        public void PersonBuilder_WhenNumberOfItemsAreLessThanFour_ShouldNotCreatePerson()
        {
            var listOfItems = new List <string>()
            {
                "Gilberto",
                "2.330",
                "2.330"
            };

            var target = new PersonBuilder(_aliasProviderMock.Object);

            target.Build(listOfItems);
        }
예제 #9
0
        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);
                          });
        }
예제 #11
0
        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()));
        }
예제 #12
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        public Person AddPerson(IPersonDto personDto)
        {
            var contactToCreate = PersonBuilder.Build(personDto);

            return(ExecuteChecking(new PeopleResource.CreateContactRequest(CreateService(), contactToCreate).Execute));
        }
예제 #16
0
        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();
            }
        }