entity framework 6 - How can I do multiple post parameters in web api? -


i have web-api, 2 tables in sql db, jt , sales. before add() database need poster specify first in uri whether he/she wants post jt table or sales. problem post method accepts 1 model binding, doesn't want 2 shown on code below. doesn't have errors when post logic in mind returns error in postman can't bind multiple parameters ('jt' , 'sales') request's content.

here code:

[responsetype(typeof(jt))] public httpresponsemessage postjt(jt jt, sales sales, [fromuri] string tran)         {             try             {                 if (modelstate.isvalid)                 {                  if (tran == null)                             {                                 return request.createresponse(httpstatuscode.unauthorized, "unauthorized access!");                             }                             else                             {                                 switch (tran)                                 {                                     case "jt": db.jts.add(jt);                                          break;                                     case "sales": db.sales_.add(sales);                                         break;                                 }                             }                             db.savechanges();                             return request.createerrorresponse(httpstatuscode.ok, "added!");                         } //below elses return messages. 

there no direct way pass multiple parameter can use below work around

this link gives complete details on web api passing multiple parameter

    $.ajax(     {         url: "samples/postalbum",         type: "post",         contenttype: "application/json",         data: json.stringify({ jt: jt, sales: sales, usertoken: usertoken }),             success: function (result) {             alert(result);         }     });            [httppost]         public string postalbum(jobject jsondata)         {           try             {                 if (modelstate.isvalid)                 {                  if (tran == null)                             {                            return request.createresponse(httpstatuscode.unauthorized,                            "unauthorized access!");                             }                             else                             {                                dynamic json = jsondata;                                jobject jtobject = json.jt;                                jobject salesobject = json.sales;                                  var jt = jtobject.toobject<jt>();                                var sales = salesobject.toobject<sales>();                                  if (jt != null)                                 {                                    db.jts.add(jt);                                  }                                  else if (sales != null)                                 {                                     db.sales_.add(sales);                                 }                              }                             db.savechanges();                     return request.createerrorresponse(httpstatuscode.ok, "added!");            }   //below elses return messages.          }