Report Modeling in ASP NET MVC

0

I have several reports in the company, and I need to migrate them from webforms to MVC. My question is .. do I need to create a template for each report? This is correct? If not, how can I do it?

For example:

I have a report that should list the daily movement (production) of a company's warehouse clerk ... the data that will be returned is:

Usuário (Login no sistema):  
Nome do Usuário: 
Quantidade de requisições atendidas: 
Quantidade de itens atendidos:

Today, inside my system, I have the User object, would it be interesting to model this report? Being that I will only use it in this place.

    
asked by anonymous 20.02.2018 / 12:10

1 answer

2

Ideally you should create ViewModels for your reports, but for the sake of performance and resource allocation it is best to keep queries in the database. The example you passed is a simple case and the query would not be too heavy depending on the volume.

However, there may be situations where by the volume of data and / or the involvement of more complex schemas, databases, and filters, you need to use views and even auxiliary tables just to store the mass generated for other reports to display. / p>

In particular, even for reports in the ReportViewer, I try to keep all DataSource queries in Stored Procedures. Facilitates the maintenance and reuse, in the case of migrations like yours, is half way.

The ViewModel for your example might look like this:

public class ProducaoViewModel {
   [Display(Name="Usuário (Login no sistema)")]
   public string LoginUsuario {get; set;}

   [Display(Name="Nome do Usuário")]
   public string NomeUsuario {get; set;}

   [Display(Name="Quantidade de requisições atendidas")]
   public int QtdRequisicoesAtendidas {get; set;} 

   [Display(Name="Quantidade de itens atendidos")]
   public int QtdItensAtendidos {get; set;}
}
    
20.02.2018 / 12:25