I am a bit new to the ASP.NET MVC framework making the move from Ruby on Rails 3 and it’s ActiveRecord. Please help me understand the place of dalAccess in the MVC.
[HttpGet]
public ActionResult copyCampaign(int Id)
{
DALAccess dalaccess = new DALAccess();
//string newid = dalaccess.CopyOffer(Id);
string newid = dalaccess.CopyOfferByCampaignId(Id);
string type = PrepareOffer4Edit(newid);
if (type == "bundle")
return RedirectToAction("bundleStep1");
else if (type == "scratchOff")
return RedirectToAction("scratchOffStep1");
else
{
return RedirectToAction("CampaignMgmt", "CampaignMgmt");
}
}
The purpose of having s DAL (Data Access Layer) is the concept of Separation of Concerns. This also works for the Single Responsibility Principle.
The DAL provide a way for you to retrieve your data objects from their source without having to worry about where the data comes from or how to transform it. This allow you to create tests specifically for your data access functionality to help identify issues.
The separation also comes in handy if and when you need to write a another application (or let’s say a 2nd front end) that uses the same data.