Exemple #1
0
        public virtual int Count(View_EVoucherUserPagingFilterModelDTO pagingModel)
        {
            Org_UserOrg org_UserOrg = _orgUserOrgRepo.Get(x => x.UserName == pagingModel.UserName);

            if (org_UserOrg == null)
            {
                return(0);
            }
            if (pagingModel.IsExpiryDate == 1)
            {
                return(_vRepo.SelectWhere(x => x.CodeUser == org_UserOrg.Code &&
                                          x.Status == pagingModel.Status &&
                                          x.EndDate >= System.DateTime.Today
                                          ).Count());
            }
            else if (pagingModel.IsExpiryDate == 2)
            {
                return(_vRepo.SelectWhere(x => x.CodeUser == org_UserOrg.Code &&
                                          x.Status == pagingModel.Status &&
                                          x.EndDate < System.DateTime.Today
                                          ).Count());
            }
            else
            {
                return(_vRepo.SelectWhere(x => x.CodeUser == org_UserOrg.Code &&
                                          x.Status == pagingModel.Status
                                          ).Count());
            }

            /* var query = this.PagingFilter(_vRepo.SelectAll(), pagingModel);
             * return query.Count();*/
        }
        public RespondData GetUserVoucher(View_EVoucherUserRS view_EVoucherUserRS)
        {
            View_EVoucherUserPagingFilterModelDTO filter = new View_EVoucherUserPagingFilterModelDTO();

            filter.UserName = System.Web.HttpContext.Current.User.Identity.Name;
            filter.Status   = 1;
            return(Success(this._service.GetUserVoucher(filter)));
        }
        public virtual RespondData Count(View_EVoucherUserRS view_EVoucherUserRS)
        {
            View_EVoucherUserPagingFilterModelDTO filter = new View_EVoucherUserPagingFilterModelDTO();

            filter.UserName = System.Web.HttpContext.Current.User.Identity.Name;

            filter.Status = 1;
            var result = this._service.Count(filter);

            return(Success(result));
        }
Exemple #4
0
        /* public IEnumerable<View_EVoucherUserDTO> GetUserVoucher(View_EVoucherUserPagingFilterModelDTO pagingModel)
         * {
         *   var query = this.PagingFilter(_vRepo.SelectWhere(x => x.CodeUser == pagingModel.CodeUser
         *                                                   && x.Status == pagingModel.Status)
         *                                                   , pagingModel);
         *   return query.OrderBy(x => x.Id).Skip(pagingModel.Start - 1).Take(pagingModel.Length).ProjectTo<View_EVoucherUserDTO>().ToList();
         * }
         */
        public IEnumerable <View_EVoucherUserDTO> GetUserVoucher(View_EVoucherUserPagingFilterModelDTO pagingModel)
        {
            Org_UserOrg org_UserOrg = _orgUserOrgRepo.Get(x => x.UserName == pagingModel.UserName);

            if (org_UserOrg == null)
            {
                return(null);
            }
            if (pagingModel.IsExpiryDate == 1)
            {
                return(_vRepo.SelectWhere(x => x.CodeUser == org_UserOrg.Code &&
                                          x.Status == pagingModel.Status &&
                                          x.EndDate >= System.DateTime.Today)
                       .OrderBy(x => x.EndDate)
                       .ProjectTo <View_EVoucherUserDTO>().ToList());
            }
            else if (pagingModel.IsExpiryDate == 2)
            {
                return(_vRepo.SelectWhere(x => x.CodeUser == org_UserOrg.Code &&
                                          x.Status == pagingModel.Status &&
                                          x.EndDate < System.DateTime.Today)
                       .OrderBy(x => x.EndDate)
                       .ProjectTo <View_EVoucherUserDTO>().ToList());
            }
            else
            {
                return(_vRepo.SelectWhere(x => x.CodeUser == org_UserOrg.Code &&
                                          x.Status == pagingModel.Status)
                       .OrderBy(x => x.EndDate)
                       .ProjectTo <View_EVoucherUserDTO>().ToList());
            }

            /*var query = this.PagingFilter(_vRepo.SelectWhere(x => x.CodeUser == pagingModel.CodeUser
             *                                              && x.Status == pagingModel.Status)
             *                                              , pagingModel);
             * return query.OrderBy(x => x.Id).Skip(pagingModel.Start - 1).Take(pagingModel.Length).ProjectTo<View_EVoucherUserDTO>().ToList();*/
        }
Exemple #5
0
        public IEnumerable <View_EVoucherUserDTO> GetPaging(View_EVoucherUserPagingFilterModelDTO pagingModel)
        {
            var query = this.PagingFilter(_vRepo.SelectAll(), pagingModel);

            return(query.OrderBy(x => x.Id).Skip(pagingModel.Start - 1).Take(pagingModel.Length).ProjectTo <View_EVoucherUserDTO>().ToList());
        }
Exemple #6
0
        protected IQueryable <View_EVoucherUser> PagingFilter(IQueryable <View_EVoucherUser> query, View_EVoucherUserPagingFilterModelDTO pagingModel)
        {
            bool?isValid = null;

            switch (pagingModel.IsValidate)
            {
            case "T":
                isValid = true;
                break;

            case "F":
                isValid = false;
                break;

            default:
                break;
            }
            query = this._vRepo.SelectWhere(x => (isValid.HasValue));
            return(query);
        }