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(); }
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(); } } }