Example #1
0
        public EditExercise(TablaEjercicios ej)
        {
            InitializeComponent();

            this.ejercicio = ej;

            this.Padding = Device.OnPlatform(
                new Thickness(10, 20, 10, 10),
                new Thickness(10, 10, 10, 10),
                new Thickness(10, 10, 10, 10));

            nombreejercicioEntry.Text = ejercicio.Nombreejercicio;
            descripcionEntry.Text     = ejercicio.Descripcion;
            comentarioEntry.Text      = ejercicio.ComentarioEjercicio;


            actualizarButton.Clicked += ActualizarButton_Clicked;
            borrarButton.Clicked     += BorrarButton_Clicked;

            // lesionesButton.Clicked += LesionesButton_Clicked;


            // listaaListView.ItemTemplate = new DataTemplate(typeof(Lesioncell));
            // listaaListView.RowHeight = 50;
        }/*
Example #2
0
        }/*
          * protected override void OnAppearing()
          * {
          * base.OnAppearing();
          * using (var datos = new DataAccess())
          * {
          *     listaaListView.ItemsSource = datos.GetLesionDeportista(this.deportista.IDDeportista);
          * }
          * }*/

        private async void AñadirButton_Clicked(object sender, EventArgs e)
        {
            string nombreejercicio      = nombreejercicioEntry.Text;
            string descripcionejercicio = descripcionEntry.Text;
            string comentarioo          = comentarioEntry.Text;

            if (string.IsNullOrEmpty(nombreejercicio))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe seleccionar el nombre del ejercicio",
                    "Aceptar");

                return;
            }
            if (string.IsNullOrEmpty(descripcionejercicio))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe seleccionar la descripción del ejercicio",
                    "Aceptar");

                return;
            }

            //creamos el deportista
            var ejercicio = new TablaEjercicios
            {
                Nombreejercicio     = nombreejercicio,
                Descripcion         = descripcionejercicio,
                clavedeportista     = deportistaa.IDDeportista,
                ComentarioEjercicio = comentarioo,

                // Salario = decimal.Parse(salarioEntry.Text),
            };

            //insertamos el deportista en la base de datos
            using (var datos = new DataAccess())
            {
                datos.InsertEjercicio(ejercicio);
                //listaListView.ItemsSource = datos.GetDeportistas();
            }

            DependencyService.Get <IMessage>().LongAlert("Ejercicio añadido");
            await App.Navigator.PopAsync(false);

            await App.Navigator.PopAsync(false);
        }
Example #3
0
        private async void Add()
        {
            /*
             * if (string.IsNullOrEmpty(this.Product.Description))
             * {
             *  await Application.Current.MainPage.DisplayAlert(
             *      Languages.Error,
             *      Languages.DescriptionError,
             *      Languages.Accept);
             *  return;
             * }
             */
            /*
             * if (this.Product.Price < 0)
             * {
             *  await Application.Current.MainPage.DisplayAlert(
             *      Languages.Error,
             *      Languages.PriceError,
             *      Languages.Accept);
             *  return;
             * }*/
            /*
             * if (this.Category == null)
             * {
             *  await Application.Current.MainPage.DisplayAlert(
             *      Languages.Error,
             *      Languages.CategoryError,
             *      Languages.Accept);
             *  return;
             * }
             */
            this.IsRunning = true;
            this.IsEnabled = false;

            //chekea la conexion
            var connection = await this.apiService.CheckConnection();

            //si la conexion a internet no ha sido exitosa
            if (!connection.IsSuccess)
            {
                this.IsRunning = false;
                this.IsEnabled = true;
                await Application.Current.MainPage.DisplayAlert(Languages.Error, connection.Message, Languages.Accept);

                return;
            }

            //para saber si se cogió o no foto

            /*
             * byte[] imageArray = null;
             * if (this.file != null)
             * {
             *  imageArray = FilesHelper.ReadFully(this.file.GetStream());
             *  this.Product.ImageArray = imageArray;
             * }
             */
            //por si el usuario cambia la categoría
            //this.Product.CategoryId = this.Category.CategoryId;
            string descripcionejercicio = this.exercise.Description;
            string nombreejercicio      = this.exercise.Name;
            string categoriaa           = this.category.Description;
            //creamos el deportista
            var ejercicio = new TablaEjercicios
            {
                Nombreejercicio = nombreejercicio,
                Descripcion     = descripcionejercicio,
                clavedeportista = deportistaa.IDDeportista,

                // Salario = decimal.Parse(salarioEntry.Text),
            };

            //insertamos el deportista en la base de datos
            using (var datos = new DataAccess())
            {
                datos.InsertEjercicio(ejercicio);
                //listaListView.ItemsSource = datos.GetDeportistas();
            }

            /*
             * var url = Application.Current.Resources["UrlAPI"].ToString();
             *
             * var prefix = Application.Current.Resources["UrlPrefix"].ToString();
             *
             * var controller = Application.Current.Resources["UrlProductsController"].ToString();
             *
             * //invocamos el metodo post del apiservice
             * var response = await this.apiService.Put(url, prefix, controller, this.Product, this.Product.ProductId, Settings.TokenType, Settings.AccessToken);
             */
            //preguntamos si lo grabó de manera exitosa

            /*
             * if (!response.IsSuccess)
             * {
             *  this.IsRunning = false;
             *  this.IsEnabled = true;
             *  await Application.Current.MainPage.DisplayAlert(Languages.Error, response.Message, Languages.Accept);
             *  return;
             * }
             *
             * var newProduct = (Product)response.Result;
             */
            //adicionamos el producto a la colección
            //var productsViewModel = ProductsViewModel.GetInstance();

            //buscamos el producto lo eliminamos y lo volvemos a crear

            /*
             * var oldProduct = productsViewModel.MyProducts.Where(p => p.ProductId == this.Product.ProductId).FirstOrDefault();
             *
             * if (oldProduct != null)
             * {
             *  productsViewModel.MyProducts.Remove(oldProduct);
             * }
             *
             *
             * productsViewModel.MyProducts.Add(newProduct);
             * productsViewModel.RefreshList();
             */
            // la ordenamos
            //viewModel.Products = viewModel.Products.OrderBy(p => p.Description).ToList();


            //si lo hizo de manera exitosa hacemos el back
            this.IsRunning = false;
            this.IsEnabled = true;
            //Desapilamos
            await App.Navigator.PopAsync(false);

            await App.Navigator.PopAsync(false);

            await App.Navigator.PopAsync(false);

            await App.Navigator.PopAsync(false);

            //PopUntilDestination(typeof(TableExercisesView));
        }