Doubts Gets / Sets

-2

My project has 3 layers, DAL, BLL, Project I use ASP.NET

I have an aspx page in the project, which has textbox containing new values for an update in the database.

In the DAL class I have entity that automatically created GETs and SETs

My question is the following as I pass values to the class.

I have always passed values via get and set, but here is already using get.

DALUsuario.Nome = AQUI QUE GOSTARIA DE RECEBER O VALOR DO TEXTBOX

Update class.

 public void AtualizarUsuario(int idUsuario)
    {
        TabUsuario DALUsuario = db.TabUsuario.Find(idUsuario);

        DALUsuario.Nome = "";
        DALUsuario.UsuarioId = "";
        DALUsuario.Senha = "";
        DALUsuario.Status = true;
        DALUsuario.DataCriacao = DateTime.Now;
        db.Entry(DALUsuario).State = EntityState.Modified;
        db.SaveChanges();

    }

ASPX Page

protected void btnEdiUsuario_Click(object sender, EventArgs e)
    {
        BLLUsuario = Usuario.DALUsuario;
        BLLUsuario.Nome = txtNomeUsuario.Text;
        BLLUsuario.Email = txtEmailUsuario.Text;            
        ...
        Usuario.AtualizarUsuario(Convert.ToInt32(Request.QueryString["Usuario"]));
    }
    
asked by anonymous 24.02.2016 / 17:22

2 answers

2

Retrieve TextBox values

var Valor = Request.Form["IdTexBox"];

But in WebForm I believe it's what you're using (aspx)

<asp:TextBox id="textBoxId" runat="server" ></asp:TextBox>
 var Valor = textBoxId.Text;

In MVC

public ActionResult Index(FormCollection form)
{
var Valor = form["IDTextBox"];

MVC getting its own UserDAL as an object

public ActionResult Index(DALUsuario user)
{
    
24.02.2016 / 17:57
0

SOLUTION

I passed an object with all its data

PÁG ASPX

protected void btnEldUsuario_Click (object sender, EventArgs e)     {         BLLUsuario = User.DALUs user;

    BLLUsuario.Nome = txtNomeUsuario.Text;
    BLLUsuario.Email = txtEmailUsuario.Text;         
    ...       

User.UpgradeUser (Convert.ToInt32 (Request.QueryString ["User"]), BLLUser);     } CLASS

public void RefreshUser (int userID, UserID objDALUser) {         DALUsuario TabUsuario = db.TabUsuario.Find (idUsuario); ;

    DALUsuario.Nome = objDALUsuario.Nome;
    DALUsuario.DataCriacao = DateTime.Now;
    db.Entry(DALUsuario).State = EntityState.Modified;
    db.SaveChanges();

}

    
25.02.2016 / 20:13