コード例 #1
0
ファイル: Family.razor.cs プロジェクト: dbillue/AV
        public async Task <List <Person> > GetPersons()
        {
            try
            {
                // Pull from local SQL Server db.
                // personList = await FamilyService.GetPeople();

                // Pull from REST API end point that queries Azure SQL Server db.
                people = await FamilyAPIService.GetFamilyAPIData("persons");

                personList = jsonUtils.Deserialize <Person>(ref person, people);

                birthStates = await FamilyAPIService.GetFamilyAPIData("states");

                birthStateList = jsonUtils.Deserialize <BirthState>(ref birthState, birthStates);

                pets = await FamilyAPIService.GetFamilyAPIData("pets");

                petList  = jsonUtils.Deserialize <Pet>(ref pet, pets);
                pettypes = await FamilyAPIService.GetFamilyAPIData("pettypes");

                petTypeList     = jsonUtils.Deserialize <PetTypes>(ref petTypes, pettypes);
                petDTO.petTypes = petTypeList;

                foreach (var pet in petList)
                {
                    pet.petType = PetService.GetPetType(pet.PetTypeId, petTypeList);
                }

                foreach (var person in personList)
                {
                    person.Pets       = PetService.GetPets(person, petList);
                    person.birthState = birthStateList;
                    person.state      = BirthState.GetBirthState(person);
                }
            }
            catch (Exception ex)
            {
                seriLogger.WriteError(ex.Message);
            }

            return(personList);
        }
コード例 #2
0
ファイル: Family.razor.cs プロジェクト: dbillue/AV
        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();
        }
コード例 #3
0
ファイル: Family.razor.cs プロジェクト: dbillue/AV
        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();
        }