I have read this and was wondering about this.
My application contains 4 Layers
- Web Project / UI
- BLL
- DAL (contains EF)
- Entity Layer
I have placed VM in UI layer as of now and its a combination of different classes. something like this
public class CompanyVMIndex
{
public CompanyVM Company { get; set; }
public BillingAddressVM BillingAddress { get; set; }
public List<ShippingAddressVM> ShippingAddress { get; set; }
public List<CompanyContactVM> CompanyContact { get; set; }
}
I am confuse now that how I can send this data from UI to BLL and then DAL. I have read by automapper but does it handle this situations, if yes then how? As of now, I have decided to move VMs to Entity Layer which will be connected to all the three layers so that I can send and receive data in the same, any other good idea?
This is how I pass data from UI to BLL
public ActionResult Create(CompanyVMIndex companyVM)
{
if (ModelState.IsValid)
{
//Calling BLL here
BLLFunction(companyVM)
}
return View("Index");
}
then in BLL and something similar in DAL with Automapper
public int BLLfunction(CompanyVMIndex CompanyVM)
{
}
now, how I can pass data as BLL does not have the definition of CompanyVMIndex which is a VM and in Web UI