Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!