예제 #1
0
        public ActionResult List(string sortBy = "Nombre", string direction = "asc", string filterBy = "All", string searchString = "",
                                 int pageSize  = 10, int page = 1)
        {
            var pageList    = ContactoService.GetContactoByPage(page, pageSize, sortBy, direction, filterBy, searchString);
            var contactosVM = Mapper.Map <IEnumerable <Contacto>, IEnumerable <ContactoListViewModel> >(pageList.ToList()).ToList();


            if (Request.IsAjaxRequest())
            {
                var result = new
                {
                    PageSize    = pageList.PageSize,
                    Pages       = pageList.PageCount,
                    CurrentPage = pageList.PageNumber,
                    Total       = pageList.TotalItemCount,
                    Records     = contactosVM
                };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            var pageVM = new ContactoPageViewModel(filterBy, sortBy);

            pageVM.SearchString = searchString;
            pageVM.List         = contactosVM;

            return(View("List", pageVM));
        }