Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
parameters in encapsulation with html form

I create a new class in my mvc project. The following are defined as properties;

public class InputBranch
{
      public int adminID { get; set; }
    
      public string authorized { get; set; }
    
      public float lat { get; set; }
    
      public float lng { get; set; }
    
      public int icon { get; set; }
}

I am sending a new object of type Input Branch as a parameter to a structure that works with the post method.

My goal is not to manually change it when a new field arrives in the inputBranch class (actually the database table), one by one, wherever it is bound.

Controllers in code;

[HttpPost]
public JsonResult addBranch(InputBranch branchData)
{
     databaseEntities st = new databaseEntities();
     branch br = new branch
     {
         ADMIN = branchData.adminID,
         NAME = branchData.authorized,
         LAT = branchData.lat,
         LNG = branchData.lng,
         ICON = branchData.icon,
         STATUS = true,
         LAST_LOGIN = DateTime.Now
     };
     st.branchs.Add(br);
     st.SaveChanges();
     return Json(true, JsonRequestBehavior.AllowGet);       
}

But here is the problem. After the input in the html form, I post it with Jquery and again, I do the input one by one manually, which I don't want. The code is here;

 $.post("/JSON/addBranch", 
 {
    adminID: adminID,
    authorized: branchName,
    lat: marker._latlng.lat, 
    lng: marker._latlng.lng,
    icon: iconNo
 }, function (t, e) { console.log("success"); });

Does anyone have a different way or a best practice suggestion for this?

My goal is to connect these parameters to a single center everywhere and execute the get-post logic from there.

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda