Пример #1
0
        protected async void Save()
        {
            IsBusy = true;
            try
            {
                if (ValidateObject())
                {
                    //await App.Current.MainPage.DisplayAlert("Validation", "All Ok", "OK");

                    PetAdditionalInfoRepository petAdditionalInfoRepository = new PetAdditionalInfoRepository();
                    petAdditionalInfo.Insurer              = Insurer.Value;
                    petAdditionalInfo.PolicyNumber         = PolicyNumber.Value;
                    petAdditionalInfo.InsurerContactNumber = InsurerContactNumber.Value;
                    petAdditionalInfo.PolicyExpiryDate     = PolicyExpiryDate.Value;
                    petAdditionalInfo.Vet = Vet.Value;
                    petAdditionalInfo.VetContactNumber = VetContactNumber.Value;
                    petAdditionalInfo.ChipNumber       = ChipNumber.Value;
                    petAdditionalInfo.PetId            = PetId.Value;
                    petAdditionalInfo.Id = Id.Value;



                    bool result = false;
                    if (Id.Value == null || Id.Value <= 0)
                    {
                        result   = petAdditionalInfoRepository.AddPetAddInfoAsync(petAdditionalInfo);
                        Id.Value = petAdditionalInfo.Id;
                    }
                    else if (Id.Value > 0)
                    {
                        petAdditionalInfo.Id = Id.Value;
                        result = petAdditionalInfoRepository.UpdatePetAddInfoAsync(petAdditionalInfo);
                        //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;
            }
        }