public virtual ActionResult WrongSegmentsList(DataSourceRequest command, WrongSegmentModel model, string sort, string sortDir)
        {
            var items = _dqQueService.GetAllWrongSegments(model.ORGKEY, model.ACCOUNTNO, model.CUST_FIRST_NAME, model.CUST_MIDDLE_NAME, model.CUST_LAST_NAME, model.PRIMARY_SOL_ID,
                                                          command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));
            //var logItems = _logger.GetAllLogs(createdOnFromValue, createdToFromValue, model.Message,
            //    logLevel, command.Page - 1, command.PageSize);
            DateTime _today    = DateTime.Now.Date;
            var      gridModel = new DataSourceResult
            {
                Data = items.Select(x => new WrongSegmentModel
                {
                    Id                 = x.ID,
                    ORGKEY             = x.ORGKEY,
                    CUST_FIRST_NAME    = x.CUST_FIRST_NAME,
                    CUST_MIDDLE_NAME   = x.CUST_MIDDLE_NAME,
                    CUST_LAST_NAME     = x.CUST_LAST_NAME,
                    GENDER             = x.GENDER,
                    CUST_DOB           = x.CUST_DOB,
                    PRIMARY_SOL_ID     = x.PRIMARY_SOL_ID,
                    SEGMENTATION_CLASS = x.SEGMENTATION_CLASS,
                    SEGMENTNAME        = x.SEGMENTNAME,
                    SUBSEGMENT         = x.SUBSEGMENT,
                    SUBSEGMENTNAME     = x.SUBSEGMENTNAME,
                    CORP_ID            = x.CORP_ID,
                    DATE_OF_RUN        = x.DATE_OF_RUN,
                    SCHEME_CODE        = x.SCHEME_CODE,
                    ACCOUNTNO          = x.ACCOUNTNO,
                }),
                Total = items.TotalCount
            };

            return(Json(gridModel));
        }
        public ActionResult List()
        {
            var model = new WrongSegmentModel();

            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
                });
            }

            _messagingService.SaveUserActivity(identity.ProfileId, "Viewed Segment / Subsegment Mapping Report", DateTime.Now);
            return(View(model));
        }