Controller
public JsonResult FillRoles()
{
return Json(BLLFile.FillUserRoles(), JsonRequestBehavior.AllowGet);
}
Code in BLL file
public static List<sp_FillUserRoles_Result> FillUserRoles()
{
using (Db_obj db = new Db_obj())
{
return db.sp_FillUserRoles().ToList();
}
}
Explanation
Now, Understand the sequence:
- View will ask controller to send data.
- FillRoles() Method in controller will request data from BLL file so it will give call to FillUserRoles method in BLL file.
- FillUserRoles() in BLL file will give call to the stored procedure in DB named sp_FillUserRoles(). This procedure will return the data and the data retrieved will be converted into a list. Note that the call to stored procedure is given using an object of DB in a very similar way we give normally to a method of other class.
- The data will be sent back to controller form here and it will send the data to the view.
Leave a comment