Example #1
0
        public ActionResult Index(DeliveryNotePage currentPage, int?page)
        {
            var htmlHelper = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext);
            var url        = htmlHelper.ContentUrl(currentPage.ContentLink);
            //var supplier = _securityRepository.GetCustomerNumber(User.Identity.Name);
            var supplier = UserManager.GetActiveCustomer(HttpContext);

            //private const string supplier = "77004216";

            if (string.IsNullOrWhiteSpace(supplier?.CustomerNo))
            {
                return(View("Index", new DeliveryNotePageViewModel(currentPage)
                {
                    ListDeliveries = new FoljesedelResponse[0],
                    Pager = new Pager(0, 0, url)
                }));
            }

            var listDeliveries      = _deliveryNoteRepository.GetFoljesedlar(supplier.CustomerNo, _ticket);
            var foljesedelResponses = listDeliveries as FoljesedelResponse[] ?? listDeliveries.ToArray();
            var pager = new Pager(foljesedelResponses?.Count() ?? 0, page, url);
            var model = new DeliveryNotePageViewModel(currentPage)
            {
                //ListDeliveries = listDeliveries != null ? listDeliveries.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize) : null,
                ListDeliveries = foljesedelResponses,
                Pager          = pager
            };

            return(View("Index", model));
        }
        public ActionResult Index(DeliveryNotePage currentPage)
        {
            var supplier = UserManager.GetActiveCustomer(HttpContext);

            if (string.IsNullOrWhiteSpace(supplier?.CustomerNo))
            {
                return(PartialView("/Views/AppPages/DeliveryNotePage/Partial/Index.cshtml", new DeliveryNotePageViewModel(currentPage)
                {
                    ListDeliveries = new FoljesedelResponse[0]
                }));
            }

            var listDeliveries = _deliveryNoteRepository.GetFoljesedlar(supplier.CustomerNo, _ticket);

            var model = new DeliveryNotePageViewModel(currentPage)
            {
                ListDeliveries = listDeliveries?.Skip(0).Take(20) ?? new FoljesedelResponse[0],
            };

            return(PartialView("/Views/AppPages/DeliveryNotePage/Partial/Index.cshtml", model));
        }