public ActividadVistaModelo(temaModelo tema, actividadModelo actividad) { this.tema = tema; this.actividad = actividad; if (tema != null) { this.BotonActivo = true; this.ResgistraActividad = true; this.FechaInicio = DateTime.Today; this.FechaFin = DateTime.Today; this.HoraInicio = DateTime.Today; this.HoraFin = DateTime.Today; this.ResgistraActividad = true; } if (actividad != null) { this.MuestraActividad = true; this.Descripcion = actividad.descripcion; this.CargaArchivo(); } }
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(); }