public static List <Model.PersonaBo> GetPersonas() { var lista = new List <Model.PersonaBo>(); var consulta = new CnaPersona(); try { var dr = consulta.Execute(); while (dr.Read()) { var obj = new Model.PersonaBo { Id = int.Parse(dr["idPersonas"].ToString()), Apellidos = dr["Apellidos"].ToString(), Nombres = dr["Nombres"].ToString(), Mail = dr["Mail"].ToString() }; lista.Add(obj); } dr.Close(); return(lista); } catch (Exception ex) { var msg = "Excepcion Controlada: " + ex.Message; throw new Exception(msg, ex); } }
public static Model.PersonaBo UpdPersona(Model.PersonaBo persona) { var query = new UpdPersona(); try { if (query.Execute(persona.Id, persona.Apellidos, persona.Nombres, persona.Mail) > 0) { return(GetPersonas().SingleOrDefault(x => x.Id == persona.Id)); } } catch (Exception ex) { var msg = "Excepcion Controlada: " + ex.Message; throw new Exception(msg, ex); } return(null); }
public static Model.PersonaBo AddPersona(Model.PersonaBo persona) { var query = new AddPersona(); try { if (query.Execute(persona.Nombres, persona.Apellidos, persona.Mail) > 0) { return(GetPersonas().Last()); } } catch (Exception ex) { var msg = "Excepcion Controlada: " + ex.Message; throw new Exception(msg, ex); } return(null); }