0
I have my Model Bank
public class Banco {
public int Id {get;set;}
public string Nome {get;set;}
}
and my model Contabancaria
public class ContaBancaria
{
public int Id{get;set;}
public string Nome {get;set;}
public Banco Banco {get;set;}
}
Let’s see, for each of them I’ll have my controller
BancoController
ContaBancariaController
So I have a "Newbank" view, it’s part of it and all of your Insert/Edit/Delete actions are from my Account Controller. But in it I have a combo with list of banks
Whose responsibility it is to fetch and send me this information from the bank to this view of mine?
From Bancocontroller for having sole responsibility and when necessary call his method to return, or in Contabancariacontroller because these data are his, he have the role of listing and sending?
I don’t know if it’s clear, it’s an example that can happen, but there can also be more than one dependency for example...
Right, so in this example of yours, you get the bank listing sent from the controller that has dependency, in case the listing is done in the Account Controller
– Rod
In my case I return a Jsonresult, so know whose responsibility it is to send the data from View
– Rod
@Rod a calling for of the method is made in the
ContaBancariaController
. But the accountability of generating the data structure is Bancodon– Tiago César Oliveira
@Rod makes more sense to store the data in a Viewbag than to create a new method to fetch data from another controller. Remember that you would be creating a controller method just to return a database listing.
– Tiago César Oliveira
Viewbag I can’t use in this case, since I’m using Select2, so I need a method that returns a json
– Rod
@Rod in this case makes more sense to have a layer to provide this data (I would use Web API). It doesn’t make much sense to put this in a controller, in my opinion. I think a controller should just control the flow of navigation and direct requests and answers - even a waiter.
– Tiago César Oliveira