public ApiResponse Update(int id, GrupoParticipante grupoParticipante) { ApiResponse resp = new ApiResponse(); if (grupoParticipante == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Conteudo vazio"); return(resp); } if (string.IsNullOrEmpty(grupoParticipante.s_descricao) == true) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Descricao nao informada"); return(resp); } DAOBase <GrupoParticipante> daoA = new DAOBase <GrupoParticipante>(); GrupoParticipante a = daoA.GetById(id); if (a == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("GrupoParticipante: " + grupoParticipante + " informada inexistente"); return(resp); } // atriuicao dos valores a.s_descricao = grupoParticipante.s_descricao; try { daoA.Update(a); resp.Success = true; resp.data = a; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }
/// <summary> /// Consulta los cursos del estudiante por medio de la cédula /// </summary> /// <param name="cedula"></param> /// <returns>Retorna lista de los cursos del estudiante</returns> public List <GrupoParticipante> consultarCursos(string cedula) { try { if (conectarBD()) { List <GrupoParticipante> cursos = new List <GrupoParticipante>(); SqlCommand comando = new SqlCommand("Select cg.Dsc_Codigo, cc.Nom_Curso, gp.Num_Calificacion_Obtenida, gp.Bool_Retiro_Certificado, gp.Fec_Fecha_Retiro from Com_Persona p, Par_Grupo_Participante gp, Cur_Grupo cg, Cur_Curso cc where p.Dsc_Identificacion=@cedula and p.Con_Persona=gp.Con_Persona and gp.Con_Grupo=cg.Con_Grupo and cg.Con_Grupo=cc.Con_Curso"); comando.Parameters.Add("@cedula", SqlDbType.VarChar).Value = cedula; comando.Connection = this.conexion; using (SqlDataReader lector = comando.ExecuteReader()) { while (lector.Read()) { GrupoParticipante nuevo = new GrupoParticipante(); nuevo.codigoGrupo = lector.GetString(0); nuevo.nombreCurso = lector.GetString(1); nuevo.calificacion = lector.GetDecimal(2); if (lector.GetBoolean(3)) { nuevo.retirado = "Retirado"; } else { nuevo.retirado = "No retirado"; } if (!lector.IsDBNull(4))//Verificar que no sea null { nuevo.fechaRetirado = lector.GetDateTime(4).ToString("dd-MM-yyyy"); } else { nuevo.fechaRetirado = "No emitido"; } cursos.Add(nuevo); } return(cursos); } } else { return(null); } } catch { return(null); } }
public ApiResponse Delete(int id) { ApiResponse resp = new ApiResponse(); if (id <= 0) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("GrupoParticipante nao informada"); return(resp); } DAOBase <GrupoParticipante> daoAlacada = new DAOBase <GrupoParticipante>(); GrupoParticipante a = daoAlacada.GetById(id); if (a == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("GrupoParticipante: " + id + " informada inexistente"); return(resp); } try { daoAlacada.Delete(a); resp.Success = true; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }
public ApiResponse Create(GrupoParticipante grupoParticipante) { ApiResponse resp = new ApiResponse(); if (grupoParticipante == null) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Conteudo vazio"); return(resp); } if (string.IsNullOrEmpty(grupoParticipante.s_descricao) == true) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add("Descricao nao informada"); return(resp); } try { DAOBase <GrupoParticipante> daoA = new DAOBase <GrupoParticipante>(); daoA.Insert(grupoParticipante); resp.Success = true; resp.data = grupoParticipante; return(resp); } catch (Exception e) { resp.Success = false; resp.ErrorList = new List <string>(); resp.ErrorList.Add(e.Message); return(resp); } }