Esempio n. 1
0
        public IActionResult Index(
            int?pageNumber, int?pageSize, string sortCol,
            string sortDir, string searchTerms)
        {
            _logger.LogInformation("In the Index of the controller!");
            return(ExecuteExceptionsHandledActionResult(() =>
            {
                OperationResult result = _customerEntityBusiness.ListItems(
                    pageNumber, pageSize, sortCol ?? "CustomerId", sortDir, searchTerms);

                ViewBag.offset = result.ObjectsDictionary["offset"];
                ViewBag.pageIndex = result.ObjectsDictionary["pageIndex"];
                ViewBag.sizeOfPage = result.ObjectsDictionary["sizeOfPage"];
                ViewBag.offsetUpperBound = result.ObjectsDictionary["offsetUpperBound"];
                ViewBag.totalRecords = result.ObjectsDictionary["totalNumberOfRecords"];
                ViewBag.totalNumberOfPages = result.ObjectsDictionary["totalNumberOfPages"];
                ViewBag.searchTerms = result.ObjectsDictionary["searchTerms"];
                ViewBag.sortCol = result.ObjectsDictionary["sortCol"];
                ViewBag.sortDir = result.ObjectsDictionary["sortDir"];

                var model = new CustomerListingViewModel {
                    CustomersList = result.ObjectsDictionary["list"] as IEnumerable <Customer>
                };

                return View(model);
            }));
        }
        public IActionResult Index()
        {
            List <CustomerListingViewModel> model = new List <CustomerListingViewModel>();

            repoCustomer.GetAll().ToList().ForEach(c =>
            {
                CustomerListingViewModel customer = new CustomerListingViewModel
                {
                    Id       = c.Id,
                    Name     = $"{c.FirstName} {c.LastName}",
                    Email    = c.Email,
                    MobileNo = c.MobileNo
                };
                model.Add(customer);
            });
            return(View(model));
        }