asp.net mvc - Call a web service from inside or outside the model? -
I'm looking for some guidance on the architecture of an application that I'm making. Here's the situation:
Our company gives reward cards to sales personnel who are then handed over to the customers (used like a debit card). For tracking purposes, the seller should request activation from our system, before the card can be used (to provide information about who gave the card and why). The front-facing app is ASP.NET MVC 2. A Windows service checks activation requests periodically and activates the company to make a web service call from the company that issued the card (in fact there are two card companies and two services) then this DB Marks the status of the card being activated in.
My solution is divided into 5 projects: Web, data (models and repositories), companies (access to two web services), service (Windows service) and test.
As is currently present, some code may look like this to go into the service of windows: using
(var repo = new repository () ) {Var card = repo.GetAllPendingCardsWithOrderAndCompany (); Foreign currency (different cards in the card) {var Client = CompanyClientFactory.GetClient (card); Try {Client.ActivateCard (Card); Card Activation = date time.Now; } Hold (exception before) {// error logging goes here}} repo.Save (); }
This works, but I can not help thinking about this issue. Should I add a method to activate an active card () that gets the web service client and tries to do real activation and logging itself? This will make Window Service very clean: using
(var repo = new repository ()) {var cards = repo.GetAllPendingCardsWithOrderAndCompany (); Foreign currency (multiple cards in card) {card.Activate (); } Repo.Save (); }
However, for this, the data project will need to refer to CompanyCollians. The company creators themselves refer to the data so it will create a circular dependency. I can combine two projects together, but it does not seem right to me (as I finally want to go to POCO and want to bring models and data to various projects).
Any ideas better to organize it?
Finally, the answer is in the card or in the class from the call O O perspective Come from thinking more deeply. Although it looks good at the first glance of the group to work together, it does not make any sense to activate itself for a card, so in any case, which comes out of the card category.
How to distinguish between different projects, for this issue, I think that uses a different interface, for which there is a great tutorial:
Comments
Post a Comment