public ActionResult List(int length, int start, string search, SearchCustomerArriveModel model) { int recordsTotal = 0; model.HotelID = comm.GetHotelId(); List <Vw_CustomerArrive_Room> data = _svustomerArrive.getAll(new PagingModel() { offset = start, limit = length, search = search }, model, out recordsTotal); //int recordsTotal = (int)_svustomerArrive.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 <Vw_CustomerArrive_Room> getAll(PagingModel page, SearchCustomerArriveModel 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 <Vw_CustomerArrive_Room>(); if (!string.IsNullOrEmpty(model.Name)) { query.Where(x => x.CustomerName.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.CustomerName.Contains(model.Name)); } if (model.RooTypeID > 0) { query.Where(x => x.Room_Type_ID == model.RooTypeID); } if (model.RoomID > 0) { query.Where(x => x.roomid == model.RoomID); } if (model.HotelID > 0) { query.Where(x => x.SysHotelID == model.HotelID); } //if (model.CheckDate) //{ // query.Where(x => x.CreateDate >= _fdate && x.CreateDate <= _tdate); //} //query.Where(x => x.Status == true); 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.Skip(offset).Take(limit).ToList(); return(rows); } }