Exemple #1
0
        public void MapToSingletonUserModelSql(UserSqlModel model, UserModel singleton)
        {
            var output = _mapper.Map <UserModel>(model);

            singleton.Avatar     = output.Avatar;
            singleton.CountryImg = output.CountryImg;
            singleton.Email      = output.Email;
            singleton.Nickname   = output.Nickname;
            singleton.Password   = output.Password;
            singleton.Playerid   = output.Playerid;
        }
        public UserSqlModel GetUser(string usuario, string dominio)
        {
            var userSql = new UserSqlModel();
            var usrLog  = (Usuario)HttpContext.Current.Session["DatosUsuario"];

            var conect = GetConnectionString("BigData");

            using (SqlConnection connection = new SqlConnection(conect))
            {
                connection.Open();
                using (SqlCommand command = connection.CreateCommand())
                {
                    string usuarioQuery = "";
                    string dominioQuery = "";
                    string sectorQuery  = "";

                    usuarioQuery = " usuarioRed = @usuario ";
                    dominioQuery = " and dominio = @dominio ";
                    //sectorQuery = " and us.sectorId = " + usrLog.sectorDefecto.sectorId.ToString();

                    command.CommandText = "select top 1 usuarioId, perfilId, usuarioRed, dominio " +
                                          "FROM Usuario " +
                                          " where " + usuarioQuery + dominioQuery + sectorQuery;

                    SqlParameter usu = new SqlParameter("@usuario", SqlDbType.VarChar);
                    usu.Value = usuario;
                    command.Parameters.Add(usu);

                    SqlParameter domi = new SqlParameter("@dominio", SqlDbType.VarChar);
                    domi.Value = dominio;
                    command.Parameters.Add(domi);

                    SqlDataReader dato = command.ExecuteReader();

                    while (dato.Read())
                    {
                        userSql.usuarioId  = dato.GetInt32(dato.GetOrdinal("usuarioId"));
                        userSql.perfilId   = dato.GetInt32(dato.GetOrdinal("perfilId"));
                        userSql.usuarioRed = dato.GetString(dato.GetOrdinal("usuarioRed"));
                        userSql.dominio    = dato.GetString(dato.GetOrdinal("dominio"));
                    }
                }
                connection.Close();
            }
            return(userSql);
        }
Exemple #3
0
 public UserModel MapToUserModel(UserSqlModel sqlModel)
 {
     return(_mapper.Map <UserModel>(sqlModel));
 }