예제 #1
0
        //-> GetList
        public async Task <GetListDTO <CustomerViewDTO> > GetList(CustomerFindDTO findDTO)
        {
            IQueryable <tblCustomer> query = db.tblCustomers.Where(x => x.deleted == null);

            if (!string.IsNullOrEmpty(findDTO.customerCode))
            {
                query = query.Where(x => x.customerCode.StartsWith(findDTO.customerCode));
            }
            if (!string.IsNullOrEmpty(findDTO.customerName))
            {
                query = query.Where(x => x.customerName.StartsWith(findDTO.customerName));
            }
            if (!string.IsNullOrEmpty(findDTO.phoneNumber))
            {
                query = query.Where(x => x.phoneNumber.StartsWith(findDTO.phoneNumber));
            }

            query = query.AsQueryable().OrderBy($"{findDTO.orderBy} {findDTO.orderDirection}");

            return(await ListingHandler(findDTO.currentPage, query));
        }
예제 #2
0
        //-> GetList
        public async Task <GetListDTO <CustomerViewDTO> > GetList(CustomerFindDTO findDTO)
        {
            var         session = HttpContext.Current.Session;
            UserViewDTO user    = (UserViewDTO)session["user"];
            int         _user   = 0;

            if (user != null)
            {
                _user = user.id;
                if (user.user_Profile == 1)
                {
                    _user = -1;
                }
            }

            IQueryable <tblCustomer> query = db.tblCustomers.Where(x => x.deleted == null);

            if (!string.IsNullOrEmpty(findDTO.code))
            {
                query = query.Where(x => x.code.StartsWith(findDTO.code));
            }
            if (!string.IsNullOrEmpty(findDTO.firstName))
            {
                query = query.Where(x => x.firstName.StartsWith(findDTO.firstName));
            }
            if (!string.IsNullOrEmpty(findDTO.lastName))
            {
                query = query.Where(x => x.lastName.StartsWith(findDTO.lastName));
            }
            if (_user != -1)
            {
                query = query.Where(x => x.cust_UserID == _user);
            }
            query = query.AsQueryable().OrderBy($"{findDTO.orderBy} {findDTO.orderDirection}");

            return(await ListingHandler(findDTO.currentPage, query));
        }
예제 #3
0
 public async Task <ActionResult> Paging(CustomerFindDTO findDTO)
 {
     return(PartialView(await handler.GetList(findDTO)));
 }