Пример #1
0
        public Task <int> SaveTridaAsync(Trida item)
        {
            var result = GetTridaAsync().Result;

            foreach (Trida t in result)
            {
                if (item.ID == t.ID)
                {
                    return(database.UpdateAsync(item));
                }
            }

            return(database.InsertAsync(item));
        }
Пример #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            student.Jmeno = txtName.Text;
            var tridy = App.Databaze.FindTridaAsync(txtClass.Text.ToUpper()).Result;

            if (tridy.Any())
            {
                student.IDTrida = tridy[0].ID;
            }
            else
            {
                Trida trida = new Trida();
                trida.Nazev = txtClass.Text.ToUpper();
                App.Databaze.SaveTridaAsync(trida);

                var result = App.Databaze.GetTridaId(trida.Nazev).Result;

                student.IDTrida = result.ID;
            }

            App.Databaze.SaveStudentAsync(student);

            NavigationService.GoBack();
        }