Example #1
0
 public TemaVistaModelo(int opcion, temaModelo tema, int idCurso)
 {
     this.tema        = tema;
     this.idCurso     = idCurso;
     this.apiServicio = new APIServicio();
     instancia        = this;
     //0 Indica que se debe de mostrar el registro del tema
     //1 Indica que se debe de mostrar la subida del archivo
     if (opcion == 0 && tema == null)
     {
         this.EsRegistro  = true;
         this.BotonActivo = true;
     }
     else
     {
         this.EsActividad = true;
         this.BotonActivo = true;
         this.cargaActividades();
     }
 }
        public async void RegistrarActividad()
        {
            if (string.IsNullOrEmpty(Nombre))
            {
                Util.mensaje(1, "El nombre esta vacĂ­o");
                return;
            }

            this.Proceso = true;

            var conexion = await new APIServicio().verificaConexion();

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

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

            client.Timeout = 10000;

            actividadModelo actividad = new actividadModelo
            {
                nombre      = this.Nombre,
                descripcion = this.Descripcion,
                fechaInicio = this.FechaInicio.ToString("yyyy-MM-dd"),
                fechaFin    = this.FechaFin.ToString("yyyy-MM-dd"),
                horaInicio  = this.HoraInicio.ToString("hh:mm tt"),
                horaFin     = this.HoraFin.ToString("hh:mm tt"),
                valor       = this.Valor,
                tema        = new temaModelo {
                    idTema = tema.idTema
                }
            };

            bool res = false;

            await Task.Run(() =>
            {
                try
                {
                    res = client.agregaActividad(actividad);
                }
                catch (Exception e)
                {
                    Util.mensaje(1, e.Message);
                }
            });

            if (!res)
            {
                Util.mensaje(1, "La actividad no pudo ser creada");
                this.Proceso = false;
                return;
            }

            TemaVistaModelo.getInstancia().cargaActividades();
            this.Proceso = false;
            Util.pantallaAnterior();
        }