Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }