public HttpResponseMessage GetAll(HttpRequestMessage request) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; var model = _khachHangService.GetAll(); var mapper = Mapper.Map <IEnumerable <KhachHang>, IEnumerable <KhachHangViewModel> >(model); response = request.CreateResponse(HttpStatusCode.OK, mapper); return response; })); }
/// <summary> /// Posts the view. /// </summary> private void PostView() { var a = currentService.GetAll(); var listModel = a.Select(b => b.ToModel()).ToList(); view.PostView(listModel); }
public HttpResponseMessage GetAll(HttpRequestMessage request, int page, int pageSize, string keyword) { return(CreateReponse(request, () => { var model = _ikhachHangService.GetAll(keyword); var query = model.Skip(page * pageSize).Take(pageSize); var responseData = Mapper.Map <IEnumerable <KhachHang>, IEnumerable <KhachHangViewModel> >(query); Paginnation <KhachHangViewModel> pagination = new Paginnation <KhachHangViewModel> { items = responseData, Page = page, TotalPage = Convert.ToInt32(Math.Ceiling((double)model.Count() / pageSize)), TotalCount = model.Count() }; return request.CreateResponse(System.Net.HttpStatusCode.OK, pagination);; })); }
public HttpResponseMessage GetAll(HttpRequestMessage request, string keyWord, int page, int pageSize = 10) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; int totalRow = 0; var model = _khachHangService.GetAll(keyWord); totalRow = model.Count(); var query = model.OrderByDescending(x => x.ID).Skip(page * pageSize).Take(pageSize); var modelViewModel = Mapper.Map <IEnumerable <KhachHang>, IEnumerable <KhachHangViewModel> >(query); var paginationSet = new PaginationSet <KhachHangViewModel>() { Items = modelViewModel, Page = page, TotalCount = totalRow, TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize) }; response = request.CreateResponse(HttpStatusCode.OK, paginationSet); return response; })); }
// GET: KhachHang public ActionResult Index(string search, int page = 1, int pagesize = 10) { return(View(khachHang.GetAll(search, page, pagesize))); }
public IActionResult GetAll() { var rs = _khachHangService.GetAll(); return(Ok(rs)); }
public async Task <IActionResult> GetByMa() { var result = await _khachHangService.GetAll(); return(Ok(result)); }
// GET: KHACHHANGs public ActionResult Index() { return(View(service.GetAll())); }