Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda