Beispiel #1
0
        private async Task UpdatePerson()
        {
            showEditPerson = false;
            showAddPets    = false;
            showPets       = false;

            if (!string.IsNullOrEmpty(petDTO.Name) && !string.IsNullOrEmpty(petDTO.NickName) && !string.IsNullOrEmpty(petDTO.petType))
            {
                pet.Name     = petDTO.Name;
                pet.NickName = petDTO.NickName;
                pet.petType  = petDTO.petType;
                pet.PersonId = person.PersonId;
                var petAdded = await PetService.AddNewPet(pet, petTypeList, pet.petType);
            }

            person.StateId = BirthState.GetBirthStateId(person, birthStateList);
            jsonPerson     = jsonUtils.CreatePatchDocument("person", person);
            await FamilyAPIService.PatchFamilyAPIData("patchperson", person.PersonId.ToString(), jsonPerson);

            personList = await GetPersons();
        }
Beispiel #2
0
        private async Task AddPerson()
        {
            person.FirstName   = personDTO.FirstName;
            person.MIddleName  = personDTO.MIddleName;
            person.LastName    = personDTO.LastName;
            person.Gender      = personDTO.Gender;
            person.Age         = personDTO.Age;
            person.DateOfBirth = personDTO.DateOfBirth;
            person.City        = personDTO.City;
            person.state       = personDTO.state;
            person.Country     = personDTO.Country;
            person.StateId     = BirthState.GetBirthStateId(person, birthStateList);
            person.CreateDate  = DateTime.Now;
            person.PersonId    = new Guid();

            // Use FamilyAPI for adding person.
            jsonPerson = jsonUtils.SerializeObj <Person>(ref person);
            id         = await FamilyAPIService.PostFamilyAPIData("persons", jsonPerson);

            // Use EFCore for adding person.
            // await FamilyService.AddPerson(person);

            if (!string.IsNullOrEmpty(petDTO.Name) && !string.IsNullOrEmpty(petDTO.NickName) && !string.IsNullOrEmpty(petDTO.petType))
            {
                pet.Name     = petDTO.Name;
                pet.NickName = petDTO.NickName;
                pet.petType  = petDTO.petType;
                pet.PersonId = Guid.Parse(id);
                var petAdded = await PetService.AddNewPet(pet, petTypeList, pet.petType);
            }

            HelperExtensions.ClearObjectValues("personDTO", personDTO);
            HelperExtensions.ClearObjectValues("petDTO", null, petDTO);

            showAddPerson = false;

            people     = string.Empty;
            personList = await GetPersons();
        }