Esempio n. 1
0
        private void AgregarRutina(object sender, EventArgs e)
        {
            Rutina rutine = new Rutina();
            var    name   = FindViewById <EditText>(Resource.Id.rutineNameAdd);

            rutine.name = name.Text;
            var content = FindViewById <EditText>(Resource.Id.rutineDescriptionAdd);

            rutine.content = content.Text;
            var kcal = FindViewById <EditText>(Resource.Id.rutineKcalAdd);

            if (kcal.Text != "")
            {
                rutine.kcal = int.Parse(kcal.Text);
            }
            else
            {
                rutine.kcal = 0;
            }
            if (!(rutine.name.Trim() != "" && rutine.content.Trim() != ""))
            {
                Toast.MakeText(this, "Debe llenar todos los campos", ToastLength.Short).Show();
                return;
            }
            if (rutine.findAndLoad(this, rutine.name))
            {
                Toast.MakeText(this, "La rutina ya esta registrada", ToastLength.Short).Show();
            }
            else
            {
                rutine.save(this);
                name.Text    = "";
                content.Text = "";
                kcal.Text    = "";
                Finish();
            }
        }