private void onSave()
        {
            try
            {
                if (!validate())
                {
                    return;
                }

                if (contact.ContactId != 0)
                {
                    RContactDao.UpdateItemAsync(contact);
                }
                else
                {
                    RContactDao.InsertItemAsync(contact);
                }

                Application.Current.MainPage.Navigation.PopAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                UtilViews.ShowAlerNotTitle("Có lỗi xảy ra, vui lòng thử lại!", "Xác nhận", () => { });
            }
        }
 private void onDelete()
 {
     try
     {
         RContactDao.DeleteItemAsync(contact);
         Application.Current.MainPage.Navigation.PopAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         UtilViews.ShowAlerNotTitle("Có lỗi xảy ra, vui lòng thử lại!", "Xác nhận", () => { });
     }
 }
Пример #3
0
        protected override async void OnStart()
        {
            //try
            //{
            //    Console.WriteLine("BACHK_ONSTART");
            //    var listContact = await ContactDao.GetItemsAsync();
            //    // init default value
            //    if (listContact.Count == 0)
            //    {
            //        // Handle when your app starts
            //        await ContactDao.InsertItemsAsync(new List<Contact>
            //        {
            //            new Contact
            //            {
            //                ContactName = "Ronaldo",
            //                ContactAge = 30,
            //                ContactAddress = "Bồ Đào Nha",
            //                ContactPhone = "0981010101",
            //                ContactEmail = "*****@*****.**",
            //                GenderId = 0,
            //                ContactGender = Gender.Male.ToString(),
            //                ContactRole = "Leader"
            //            },
            //            new Contact
            //            {
            //                ContactName = "Messi",
            //                ContactAge = 30,
            //                ContactAddress = "Argentina",
            //                ContactPhone = "0982020202",
            //                ContactEmail = "*****@*****.**",
            //                GenderId = 0,
            //                ContactGender = Gender.Male.ToString(),
            //                ContactRole = "Member"
            //            }
            //        });
            //    }


            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e);
            //}


            try
            {
                var listContact = RContactDao.GetItemsAsync();
                var generateId  = 0;
                if (listContact.Count == 0)
                {
                    // init default value
                    RContactDao.InsertItemsAsync(new List <RContact>
                    {
                        new RContact
                        {
                            ContactName    = "RRonaldo",
                            ContactAge     = 30,
                            ContactAddress = "Bồ Đào Nha",
                            ContactPhone   = "0981010101",
                            ContactEmail   = "*****@*****.**",
                            GenderId       = 0,
                            ContactGender  = Gender.Male.ToString(),
                            ContactRole    = "Leader",
                            ContactId      = generateId++
                        },
                        new RContact
                        {
                            ContactName    = "RMessi",
                            ContactAge     = 30,
                            ContactAddress = "Argentina",
                            ContactPhone   = "0982020202",
                            ContactEmail   = "*****@*****.**",
                            GenderId       = 0,
                            ContactGender  = Gender.Male.ToString(),
                            ContactRole    = "Member",
                            ContactId      = generateId++
                        }
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }