示例#1
0
        public IList <Customer> GetCustomers(SearchCustomerModel searchCustomerModel)
        {
            if (!searchCustomerModel.Validate())
            {
                throw new ArgumentException("SearchCustomerModel didn't pass validation");
            }

            return(_context.Query <Customer>($@"
                 SELECT
                        CustomerId
                        ,FirstName
                        ,LastName
                        ,CreatedDate
                        ,Email
                        ,CustomerPassword
                        ,CustomerPhone
                        ,CustomerRole = CustomerRoleId
                    
                        ,Address1
                        ,Address2
                        ,City
                        ,Country
                    FROM
                        Customers
                    {CreateQuery(searchCustomerModel)}
                    ORDER BY {searchCustomerModel.OrderBy}{(searchCustomerModel.IsDesc ? " DESC" : string.Empty)}
                    OFFSET @skip ROWS
                    FETCH NEXT @take ROWS ONLY
                ", new
            {
                skip = searchCustomerModel.Skip,
                take = searchCustomerModel.Take
            }
                                             ).ToList());
        }
示例#2
0
        public async Task <ActionResult> LayuiCustomerList(SearchCustomerModel model)
        {
            var result = await _customerService.GetPagedCustomers(model.Username, model.Email, model.PageIndex - 1, model.PageSize);

            List <CustomerModel> customers = result.Item2.Select(x =>
            {
                CustomerModel customerModel = new CustomerModel
                {
                    Id           = x.Id,
                    Username     = x.Username,
                    Email        = x.Email,
                    Active       = x.Active,
                    CreationTime = x.CreationTime.ToString("yyyy-MM-dd")
                };
                return(customerModel);
            }).ToList();

            return(Json(new { code = 0, data = customers, count = result.Item1 }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public async Task <ActionResult> BootstrapCustomerList(SearchCustomerModel model)
        {
            var result = await _customerService.GetPagedCustomers(model.Username, model.Email, model.PageIndex - 1, model.PageSize);

            List <CustomerModel> customers = result.Item2.Select(x =>
            {
                CustomerModel customerModel = new CustomerModel
                {
                    Id           = x.Id,
                    Username     = x.Username,
                    Email        = x.Email,
                    Active       = x.Active,
                    CreationTime = x.CreationTime.ToString("yyyy-MM-dd")
                };
                return(customerModel);
            }).ToList();

            return(Json(new { rows = customers, total = result.Item1 }));
        }
示例#4
0
        public ActionResult List(int length, int start, string search, SearchCustomerModel model)
        {
            int recordsTotal         = 0;
            List <tbl_Customer> data = _customerManage.getAll(new PagingModel()
            {
                offset = start, limit = length, search = search
            }, model, out recordsTotal);
            //int recordsTotal = (int)_customerManage.countAll(new PagingModel() { offset = start, limit = length, search = search });
            int recordsFiltered = recordsTotal;
            int draw            = 1;

            try { draw = int.Parse(Request.Params["draw"]); }
            catch { }
            return(Json(new
            {
                draw,
                recordsTotal,
                recordsFiltered,
                data
            }, JsonRequestBehavior.AllowGet));
        }
        public List <tbl_Customer> getAll(PagingModel page, SearchCustomerModel model, out int count)
        {
            if (page.search == null)
            {
                page.search = "";
            }

            //  ServiceStackHelper.Help();
            //  LicenseUtils.ActivatedLicenseFeatures();
            //search again
            DateTime _fdate;
            DateTime _tdate;

            DateTime.TryParse(model.Fdate, CultureInfo.GetCultureInfo("vi-vn"), DateTimeStyles.None, out _fdate);
            DateTime.TryParse(model.Tdate, CultureInfo.GetCultureInfo("vi-vn"), DateTimeStyles.None, out _tdate);
            _tdate = _tdate.AddDays(1);
            using (var db = _connectionData.OpenDbConnection())
            {
                var query = db.From <tbl_Customer>();
                if (!string.IsNullOrEmpty(model.Name))
                {
                    query.Where(x => x.Name.Contains(model.Name));
                }
                if (!string.IsNullOrEmpty(model.Email))
                {
                    query.Where(x => x.Email == model.Email.Trim());
                }

                if (!string.IsNullOrEmpty(model.Phone))
                {
                    query.Where(x => x.Phone == model.Phone.Trim());
                }

                if (!string.IsNullOrEmpty(model.Name))
                {
                    query.Where(x => x.Name.Contains(model.Name));
                }
                if (model.CheckDate)
                {
                    query.Where(x => x.CreateDate >= _fdate && x.CreateDate <= _tdate);
                }
                //query.Where(x => x.Status == true);
                if (!comm.IsSuperAdmin())
                {
                    query.Where(x => x.SysHotelID == comm.GetHotelId());
                }
                query.OrderByDescending(x => x.Id);

                int offset = 0;
                try
                {
                    offset = page.offset;
                }
                catch
                {
                }

                int limit = 10; //int.Parse(Request.Params["limit"]);
                try
                {
                    limit = page.limit;
                }
                catch
                {
                }

                var rows = db.Select(query);
                count = rows.Count;
                rows  = rows.Where(e => (e.Name ?? "").Contains(page.search)).Skip(offset).Take(limit).ToList();

                return(rows);
            }
        }
        public ActionResult ShowPager(SearchCustomerModel searchCustomer)
        {
            searchCustomer.Count = _customerRepository.Count(searchCustomer);

            return(PartialView("_Pager", searchCustomer));
        }
 public ActionResult PagesData(SearchCustomerModel searchCustomer)
 {
     return(PartialView("CustomersData", _customerRepository.GetCustomers(searchCustomer)));
 }