Wednesday, August 28, 2013

Data travel from DAL to MVC View

Data travel from DAL to MVC View

ASP.NET MVC4
I have Business layer DLL which communicates to my DAL and retrieves
classes like:
public class ProductionParameter
{
public string CompanyCode { get; set; }
public string UnitCode { get; set; }
public string ItemDescriptionLocal { get; set; }
public string ItemDescriptionEnglish { get; set; }
public string ConsumedItemDescriptionLocal { get; set; }
public string ConsumedItemDescriptionEnglish { get; set; }
public string LotCategory1Description { get; set; }
public string LotCategory2Description { get; set; }
public string LotCategory3Description { get; set; }
public string LotCategory1Code { get; set; }
public string LotCategory2Code { get; set; }
public string LotCategory3Code { get; set; }
public string LineCode { get; set; }
public string LineCodeDisplay { get; set; }
public List<Pallet> PalletsProduced { get; set; }
}
My controller gets the above info but my View doesnt need all the above.
For example lets say i get 3 production parameters classes that each one
has 20 Pallets. It means that each productionparameter has 20 pallets
produced.
I want to show to my MVC View consolidated data for each production
parameter.
How i do it correctly?
Standard Case:
Do i create in Models a class with exactly the info i need for the view
and then define this class in the @model directive?
AJAX:
What changes if i want to make this via AJAX? My AJAX call will return the
consolidated data or the full data and let AngularJS or Jquery make the
consolidation on the client?

No comments:

Post a Comment