public ActionResult GetAll(int?page) { string ErrorMessage = string.Empty; List <Product> products = new List <Product>(); List <ProductVM> productsVM = new List <ProductVM>(); //TODO : Calling Data Layer var IsSuccess = dalProduct.GetAll(out ErrorMessage, out products); if (IsSuccess) { if (products.Count > 0) { //TODO : Mapping foreach (var item in products) { productsVM.Add(new ProductVM { Id = item.Id, Name = item.Name, Price = item.Price, CategoryId = item.CategoryId, CategoryName = item.CategoryName, IsActive = item.IsActive, IsActiveText = item.IsActive ? "Yes" : "No" }); } } else { ErrorMessage = ErrorClass + " | " + "No rows!"; throw new Exception(ErrorMessage); } } else { ErrorMessage = ErrorClass + " | " + ErrorMessage; throw new Exception(ErrorMessage); } return(View(productsVM.ToPagedList(page ?? 1, 10))); }