Esempio n. 1
0
        public CursoVistaModelo(cursoModelo curso)
        {
            this.idCurso = curso.idCurso;

            instancia = this;
            //Si el curso id es igual a -1 entonces se debe registrar un nuevo curso
            if (idCurso == -1)
            {
                this.RegistroCurso = true;
            }
            else
            {
                this.EsTema = true;
                this.cargaTemas();
            }
        }
Esempio n. 2
0
        private async void RegistraTema()
        {
            if (string.IsNullOrEmpty(Nombre))
            {
                Util.mensaje(1, "El nombre esta vacío");
                return;
            }

            this.Proceso = true;

            var conexion = await this.apiServicio.verificaConexion();

            if (!conexion.IsSuccess)
            {
                this.Proceso = false;
                Util.mensaje(1, conexion.Mensaje);
                return;
            }

            var client = MainVistaModelo.getInstancia().getWS();

            client.Timeout = 10000;

            cursoModelo cursoN = new cursoModelo {
                idCurso = this.idCurso
            };

            temaModelo tema = new temaModelo {
                nombre = this.Nombre, curso = cursoN
            };

            bool res = false;

            await Task.Run(() => res = client.agregaTema(tema));

            if (!res)
            {
                Util.mensaje(1, "El tema no pudo ser creado");
                this.Proceso = false;
                return;
            }

            CursoVistaModelo.getInstancia().cargaTemas();
            this.Proceso = false;
            Util.pantallaAnterior();
        }
Esempio n. 3
0
        public async void EliminarTema()
        {
            bool res = await Application.Current.MainPage.DisplayAlert("¡ATENCIÓN!",
                                                                       "Esta a punto de eliminar el tema '" + this.tema.nombre + "'", "ACEPTAR", "CANCELAR");

            if (res)
            {
                this.Proceso = true;

                var cliente = MainVistaModelo.getInstancia().getWS();

                bool resS = false;

                await Task.Run(() =>
                {
                    try
                    {
                        resS = cliente.eliminaTema(new temaModelo {
                            idTema = this.tema.idTema
                        });
                    }
                    catch (Exception e) { Util.mensaje(1, e.Message); }
                });

                if (!resS)
                {
                    Util.mensaje(1, "No se ha podido eliminar el tema");
                }
                else
                {
                    CursoVistaModelo.getInstancia().cargaTemas();
                    this.Proceso = false;
                    Util.pantallaAnterior();
                }
            }
        }