public async Task <IActionResult> Index(string keyword, int pageIndex = 1, int pageSize = 5) { var request = new GetQLLuongPagingRequest() { keyword = keyword, pageIndex = pageIndex, pageSize = pageSize }; var result = await _qLLuongApiClient.GetAllWithPaging(request); if (TempData["result"] != null) { ViewBag.Success = true; ViewBag.SuccessMessage = TempData["result"]; } return(View(result.ResultObj)); }
public async Task <IActionResult> GetAllWithPaging([FromQuery] GetQLLuongPagingRequest request) { var qll = await _qLLuongServices.GetAllWithPaging(request); return(Ok(qll)); }
public async Task <APIResult <PageResult <QLLuongViewModel> > > GetAllWithPaging(GetQLLuongPagingRequest request) { var query = (from sq in _context.SiQuans join qlluong in _context.QLLuongs on sq.IDSQ equals qlluong.IDSQ join lcb in _context.LuongCoBans on qlluong.IDLuongCB equals lcb.IDLuongCB join qlqh in _context.QLQuanHams on qlluong.IDQLQH equals qlqh.IDQLQH join hsl in _context.HeSoLuongTheoQuanHams on qlqh.IDHeSoLuongTheoQH equals hsl.IDHeSoLuongQH join qlcv in _context.QLChucVus on qlluong.IDQLCV equals qlcv.IDQLCV join cv in _context.ChucVus on qlcv.IDCV equals cv.IDCV join hspc in _context.HeSoPhuCapTheoChucVus on cv.IDCV equals hspc.IDCV select new QLLuongViewModel { IDLuong = qlluong.IDLuong, IDSQ = qlluong.IDSQ, HoTen = sq.HoTen, HeSoLuong = hsl.HeSoLuong, HeSoPhuCap = hspc.HeSoPhuCap, LuongCB = lcb.LuongCB, Luong = Convert.ToUInt64(hsl.HeSoLuong * lcb.LuongCB + hspc.HeSoPhuCap * lcb.LuongCB) }); if (!string.IsNullOrEmpty(request.keyword)) { query = query.Where(p => p.HoTen.Contains(request.keyword) || p.IDSQ.Equals(request.keyword)); } int totalRow = await query.CountAsync(); var data = await query.Skip((request.pageIndex - 1) *request.pageSize) .Take(request.pageSize) .Select(x => new QLLuongViewModel() { IDLuong = x.IDLuong, IDSQ = x.IDSQ, HoTen = x.HoTen, HeSoLuong = x.HeSoLuong, HeSoPhuCap = x.HeSoPhuCap, LuongCB = x.LuongCB, Luong = x.Luong }).ToListAsync(); var pageResult = new PageResult <QLLuongViewModel>() { TotalRecord = totalRow, PageIndex = request.pageIndex, PageSize = request.pageSize, Items = data }; return(new APISuccessedResult <PageResult <QLLuongViewModel> >(pageResult)); }
public async Task <APIResult <PageResult <QLLuongViewModel> > > GetAllWithPaging(GetQLLuongPagingRequest request) { var client = _httpClientFactory.CreateClient(); client.BaseAddress = new Uri(_configuration["BaseAddress"]); var session = _httpContextAccessor.HttpContext.Session.GetString("Token"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", session); var reponse = await client.GetAsync($"/api/QLLuongs/paging?pageIndex={request.pageIndex}&pageSize={request.pageSize}&keyword={request.keyword}"); var body = await reponse.Content.ReadAsStringAsync(); var user = JsonConvert.DeserializeObject <APISuccessedResult <PageResult <QLLuongViewModel> > >(body); return(user); }