public virtual ActionResult DistinctList(DataSourceRequest command, DistinctDocsModel model, string sort, string sortDir)
        {
            var items = _dqQueService.GetAllDistinctDocs(model.ACCT_NAME, model.CIF_ID, model.SOL_ID, model.CUSTOMERTYPE, command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));

            DateTime _today    = DateTime.Now.Date;
            var      gridModel = new DataSourceResult
            {
                Data = items.Select(x => new DistinctDocsModel
                {
                    Id               = x.ID,
                    ACCT_NAME        = x.ACCT_NAME,
                    DUE_DATE         = x.DUE_DATE,
                    BRANCH_NAME      = x.BRANCH_NAME,
                    FREZ_REASON_CODE = x.FREZ_REASON_CODE,
                    SOL_ID           = x.SOL_ID,
                    ACCTOFFICER_CODE = x.ACCTOFFICER_CODE,
                    ACCTOFFICER_NAME = x.ACCTOFFICER_NAME,
                    CIF_ID           = x.CIF_ID,
                    CUSTOMERTYPE     = x.CUSTOMERTYPE
                }),
                Total = items.TotalCount
            };

            return(Json(gridModel));
        }
        public virtual ActionResult ExportExcelAll(DistinctDocsModel model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(AccessDeniedView());
            }
            var items = _dqQueService.GetAllDistinctDocs(model.ACCT_NAME, model.CIF_ID, model.SOL_ID);

            try
            {
                byte[] bytes = _exportManager.ExportDocumentsToXlsx(items);
                identity = ((CustomPrincipal)User).CustomIdentity;
                _messagingService.SaveUserActivity(identity.ProfileId, "Downloaded Customers With Outstanding Documents Report", DateTime.Now);
                return(File(bytes, MimeTypes.TextXlsx, "outstandingDocs.xlsx"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
        public ActionResult List()
        {
            var model = new DistinctDocsModel();

            if (!User.Identity.IsAuthenticated)
            {
                return(AccessDeniedView());
            }

            identity           = ((CustomPrincipal)User).CustomIdentity;
            _permissionservice = new PermissionsService(identity.Name, identity.UserRoleId);

            IQueryable <CM_BRANCH> curBranchList = db.CM_BRANCH.OrderBy(x => x.BRANCH_NAME); //.Where(a => a.BRANCH_ID == identity.BranchId);

            if (_permissionservice.IsLevel(AuthorizationLevel.Enterprise))
            {
            }
            else if (_permissionservice.IsLevel(AuthorizationLevel.Regional))
            {
                curBranchList = curBranchList.Where(a => a.REGION_ID == identity.RegionId);
            }
            else if (_permissionservice.IsLevel(AuthorizationLevel.Zonal))
            {
                curBranchList = curBranchList.Where(a => a.ZONECODE == identity.ZoneId).OrderBy(a => a.BRANCH_NAME);
            }
            else if (_permissionservice.IsLevel(AuthorizationLevel.Branch))
            {
                curBranchList = curBranchList.Where(a => a.BRANCH_ID == identity.BranchId).OrderBy(a => a.BRANCH_NAME);
            }
            else
            {
                curBranchList = curBranchList.Where(a => a.BRANCH_ID == "-1");
            }

            model.Branches = new SelectList(curBranchList, "BRANCH_ID", "BRANCH_NAME").ToList();


            if (_permissionservice.IsLevel(AuthorizationLevel.Enterprise))
            {
                model.Branches.Add(new SelectListItem
                {
                    Value    = "0",
                    Text     = "All",
                    Selected = true
                });
            }

            model.CustomerTypes.Add(new SelectListItem
            {
                Value = "Individual",
                Text  = "Individual",
            });

            model.CustomerTypes.Add(new SelectListItem
            {
                Value = "Corporate",
                Text  = "Corporate",
            });

            model.CustomerTypes.Add(new SelectListItem
            {
                Value    = "0",
                Text     = "All",
                Selected = true
            });

            _messagingService.SaveUserActivity(identity.ProfileId, "Viewed Customer Outstanding Documents Report", DateTime.Now);
            return(View(model));
        }