Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which layer is the best to add a new method?
Message
 
 
À
13/05/2015 12:57:20
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01619738
Message ID:
01619755
Vues:
39
>>Say, in Accounts API controller I have this code:
>>
>>
>>private void SetOperatorAndSalespoint(Accounts account)
>>        {
>>            account.Operator = OperatorSession.OpCode;
>>            account.Salespoint = SysManagerConstants.SYSMANAGER_SALESPOINT_NAME;
>>            account.DateTime = DateTime.Now;
>>        }
>>
>>which is called when account is updated and it works fine. But when the same code is called from the Invoices API controller when invoice is updated, the OperatorSession is null. I also believe it used to work and got broken quite recently but I am not sure where to start investigating.
>
>So where does the 'OperatorSession' come from ?
>IAC, a message handler in the pipeline is not difficult to implement and looks to me like a good place for the above code (always assuming that it is possible to identify incoming requests which require the addition).....

With the help of my colleague we figured out why the OperatorSession was null in one case and not null in another. We do have Authentication attribute. I was thinking it's an MVC attribute but it's apparently something developed internally for this application. If that attribute is set, the OperatorSession is eventually not null. If the class doesn't have that attribute, the property of the class is null.

I removed the Authentication attribute from the class level for Invoices controller as I call the same controller from two different areas right now (Customer Accounts and Guests) and I was thinking it needs to have different rights depending on the caller. But that doesn't seem to work, so I put the original code for the attribute back in and it resolved this problem.

It didn't, of course, resolve the problem of the thread as how to use one generic method of updating properties that may exist only for some classes. I will look closer at your suggestion and also try to discuss this problem in our group.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform