c# - How to create multiple POST methods on an Azure Mobile Service? -


i have azure mobile service multiple controllers. 1 of controllers (testsetcontroller) has methods check on insert.

problem need solve: testset table has 2 different types of testsets, 1 local team , field team. table contains data both , records differentiated "teamtype" field says if local team inserted testset or field team did. on insert want check if similar testset exists inserted other team. want compare testsets (if found) other inserts/updates on same table if testsets different.

however, keep getting error:

exception=system.invalidoperationexception: multiple actions found match request:  posttestsetdto on type sbp_ctservice.controllers.testsetcontroller checkfordiscrepancy on type sbp_ctservice.controllers.testsetcontroller comparetestpointattempts on type sbp_ctservice.controllers.testsetcontroller    @ system.web.http.controllers.apicontrolleractionselector.actionselectorcacheitem.selectaction(httpcontrollercontext controllercontext)    @ system.web.http.controllers.apicontrolleractionselector.selectaction(httpcontrollercontext controllercontext)    @ system.web.http.apicontroller.executeasync(httpcontrollercontext controllercontext, cancellationtoken cancellationtoken)    @ system.web.http.dispatcher.httpcontrollerdispatcher.<sendasync>d__1.movenext(), id=f07761ae-1be7-4f00-90b0-685dd0c108f3, category='app.request' 

here's controller:

    public class testsetcontroller : tablecontroller<testsetdto>     {         private context context;          protected override void initialize(httpcontrollercontext controllercontext)         {             base.initialize(controllercontext);             context = new context();             domainmanager = new simplemappedentitydomainmanager<testsetdto, testset>(context, request, services, testset => testset.id);         }          // tables/testset         [queryableexpand("testpointattempts")]         public iqueryable<testsetdto> getalltestsetdto()         {             return query();          }          // tables/testset/48d68c86-6ea6-4c25-aa33-223fc9a27959         public singleresult<testsetdto> gettestsetdto(string id)         {             return lookup(id);         }          // patch tables/testset/48d68c86-6ea6-4c25-aa33-223fc9a27959         public task<testsetdto> patchtestsetdto(string id, delta<testsetdto> patch)         {              return updateasync(id, patch);         }          // post tables/testset/48d68c86-6ea6-4c25-aa33-223fc9a27959         public async task<ihttpactionresult> posttestsetdto(testsetdto item)         {             testset testset = automapper.mapper.map<testsetdto, testset>(item);             this.checkfordiscrepancy(testset);              testsetdto current = await insertasync(item);             return createdatroute("tables", new { id = current.id }, current);         }          // delete tables/testset/48d68c86-6ea6-4c25-aa33-223fc9a27959         public task deletetestsetdto(string id)         {              return deleteasync(id);         }          public testset checkfordiscrepancy(testset sourcetestset)         {              // set team type search opposite 1 being posted.             string searchteamtype = null;             if (sourcetestset.testteamtype == "d")             {                 searchteamtype = "f";             }             if (sourcetestset.testteamtype == "f")             {                 searchteamtype = "d";             }              var testsettable = context.testsets;              testset foundtestset = (from ts in testsettable                                     ts.tileid == sourcetestset.tileid && ts.scenarioid == sourcetestset.scenarioid && ts.testteamtype.startswith(searchteamtype)                                     select ts).singleordefault();              // if no other test set found opposing team test set missing.             // else testset found continue checks.             if (foundtestset == null)             {                 sourcetestset.discrepancytypeid = discrepancytype.missing.tostring();             }             else             {                 var testpointattempttable = context.testpointattempts;                  // of associated testpointattempts each testset.                 sourcetestset.testpointattempts = (from tpa in testpointattempttable                                                    tpa.testsetid == sourcetestset.id                                                    orderby tpa.testattemptnumber                                                    select tpa).tolist<testpointattempt>();                  foundtestset.testpointattempts = (from tpa in testpointattempttable                                                   tpa.testsetid == foundtestset.id                                                   orderby tpa.testattemptnumber                                                   select tpa).tolist<testpointattempt>();                  bool matchingtestsets = comparetestpointattempts(sourcetestset.testpointattempts, foundtestset.testpointattempts);                  if (!matchingtestsets)                 {                     sourcetestset.discrepancytypeid = discrepancytype.discrepancy.tostring();                     sourcetestset.discrepancytestsetid = foundtestset.id;                 }              }              return sourcetestset;         }          public bool comparetestpointattempts(ienumerable<testpointattempt> sourcetpas, ienumerable<testpointattempt> foundtpas)         {             bool pass = false;              // first check if total number of testpointattempts same             if (sourcetpas.count() == foundtpas.count())             {                 foreach (testpointattempt stpa in sourcetpas)                 {                     bool foundmatch = false;                      foreach (testpointattempt ftpa in foundtpas)                     {                         if (stpa.testattemptnumber == ftpa.testattemptnumber)                         {                             if (stpa.talkin == ftpa.talkin && stpa.talkout == ftpa.talkout)                             {                                 foundmatch = true;                             }                         }                     }                      if (!foundmatch)                     {                         return pass;                     }                 }                  // foreach loop finished meaning matches found                 pass = true;             }              return pass;         }          /// <summary>         /// type of discrepancy testset can have.         /// </summary>         public enum discrepancytype         {             discrepancy,             missing,             none         }     } } 

i'm using data transfer objects (dtos) map between entity models. appreciated. i've looked @ different answers on stackoverflow asp.net talk updating config.routes. azure mobile service might have different requirements simple asp.net website though.

it simple making 2 methods private , leaving actual post method public. asp.net make routes automatically public methods.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -