Exemple #1
0
        public void paises(long country_id = 0)
        {
            exist_countries exist_countries      = new exist_countries();
            var             collection_countries = exist_countries.Consultar(0);

            collection_countries.Insert(0, new CountriesDto {
                name = GeralResource.RecRes(623), country_id = 0
            });

            var arrSelectList = new SelectList(collection_countries, "country_id", "name", country_id);

            ViewBag.userLog = getUser();
            ViewBag.paises  = arrSelectList;
        }
Exemple #2
0
        public Exist_UsersDtoCollection ConsultarUsuarios(long id)
        {
            try
            {
                Exist_UsersDtoCollection usuarios      = new Exist_UsersDtoCollection();
                exist_countries          countryGetter = new exist_countries();


                string sql = "SELECT * FROM exist_users";
                if (id != 0)
                {
                    sql = sql + " WHERE user_id=" + id;
                }
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                usuarios = GetExist_UsersDtoCollection(tabela);

                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        private Exist_UsersDtoCollection GetExist_UsersDtoCollection(DataTable tabela)
        {
            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                foreach (DataRow item in tabela.Rows)
                {
                    Exist_UsersDto usuario = new Exist_UsersDto();
                    usuario.user_id      = Convert.ToInt64(item["user_id"]);
                    usuario.user_email   = item["user_email"].ToString();
                    usuario.user_company = item["user_company"].ToString();
                    usuario.user_name    = item["user_name"].ToString();
                    usuario.user_phone   = item["user_phone"].ToString();
                    usuario.dose         = Convert.ToInt64(item["dose"]);
                    usuario.user_blocked = Convert.ToBoolean(item["user_blocked"]);
                    usuario.currency_id  = Convert.ToInt64(item["currency_id"]);
                    if (item["user_accesslevel"] != DBNull.Value)
                    {
                        usuario.user_accesslevel = Convert.ToInt32(item["user_accesslevel"]);
                    }
                    if (item["user_date_expire"] != DBNull.Value)
                    {
                        usuario.user_date_expire = Convert.ToDateTime(item["user_date_expire"]);
                    }
                    if (item["user_date_register"] != DBNull.Value)
                    {
                        usuario.user_date_register = Convert.ToDateTime(item["user_date_register"]);
                    }
                    if (item["date_answer"] != DBNull.Value)
                    {
                        usuario.date_answer = Convert.ToDateTime(item["date_answer"]);
                    }
                    if (item["last_name"] != DBNull.Value)
                    {
                        usuario.last_name = item["last_name"].ToString();
                    }
                    if (item["treatment"] != DBNull.Value)
                    {
                        usuario.treatment = item["treatment"].ToString();
                    }
                    usuario.user_blocked = Convert.ToBoolean(item["user_blocked"]);
                    exist_countries paises       = new exist_countries();
                    long            user_country = Convert.ToInt64(item["user_country"]);

                    usuario.user_country = user_country;

                    var collection = paises.Consultar(user_country);
                    if (collection.Count > 0)
                    {
                        usuario.countries = collection[0];
                    }

                    if (item["comments"] != DBNull.Value)
                    {
                        usuario.comments = item["comments"].ToString();
                    }
                    if (item["user_admin"] != DBNull.Value)
                    {
                        usuario.user_admin = Convert.ToBoolean(item["user_admin"]);
                    }
                    usuario.user_password = item["user_password"].ToString();

                    if (tabela.Columns.Contains("chbx"))
                    {
                        usuario.chbx = Convert.ToBoolean(item["chbx"]);
                    }
                    usuarios.Add(usuario);
                }
                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }