Exemplo n.º 1
0
        protected async void Save()
        {
            IsBusy = true;
            try
            {
                if (ValidateObject())
                {
                    //await App.Current.MainPage.DisplayAlert("Validation", "All Ok", "OK");

                    PetAdditionalInfoRepository petAdditionalInfoRepository = new PetAdditionalInfoRepository();
                    petKennelClub.KennelClubName           = KennelClubName.Value;
                    petKennelClub.KennelRegistrationNumber = KennelRegistrationNumber.Value;
                    petKennelClub.KennelContactNumber      = KennelContactNumber.Value;
                    petKennelClub.PetId = PetId.Value;
                    petKennelClub.Id    = Id.Value;



                    bool result = false;
                    if (Id.Value == null || Id.Value <= 0)
                    {
                        result   = petAdditionalInfoRepository.AddPetKennelInfoAsync(petKennelClub);
                        Id.Value = petKennelClub.Id;
                    }
                    else if (Id.Value > 0)
                    {
                        petKennelClub.Id = Id.Value;
                        result           = petAdditionalInfoRepository.UpdatePetKennelInfoAsync(petKennelClub);
                        //Id.Value = pet.Id;
                    }

                    if (result)
                    {
                        await App.Current.MainPage.DisplayAlert("Data Saved", "All Ok", "OK");
                    }
                }

                else
                {
                    await App.Current.MainPage.DisplayAlert("Validation", "Errors during validation", "OK");
                }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e);
                throw;
            }
            finally
            {
                IsBusy = false;
            }
        }