public async Task <IActionResult> GetAllAccountByName(int iPageNum, int iPageSize, string fullName, string email, string phone, string address)
        {
            Paggings paggings = new Paggings
            {
                PageNum  = iPageNum == 0 ? 1 : iPageNum,
                PageSize = iPageSize == 0 ? int.MaxValue : iPageSize
            };

            if (iPageNum <= 0 || iPageSize <= 0)
            {
                return(BadRequest(new { Message = "Invalid iPageNum or iPageSize!" }));
            }

            apiResult.Pagging.PageNum       = paggings.PageNum;
            apiResult.Pagging.PageSize      = paggings.PageSize;
            apiResult.AccountInfo.FULL_NAME = fullName;
            apiResult.AccountInfo.EMAIL     = email;
            apiResult.AccountInfo.PHONE     = phone;
            apiResult.AccountInfo.ADDRESS   = address;

            if (fullName is null && email is null && phone is null && address is null)
            {
                var employee = await _accountService.GetAllAccountWithPagging(paggings);

                employee.AppResult.DataResult = new { employee.ListAccount, employee.Pagging };
                return(Ok(employee.AppResult));
            }
        public async Task <AccountViewModel> GetAllAccountWithPagging(Paggings paggings)
        {
            var oObject = await _accountRepository.GetAllWithPaggingAsync(paggings);

            paggings.TotalNum = oObject.FirstOrDefault <AccountInfo>().TOTAL_COUNT;
            model.Pagging     = paggings;
            model.ListAccount = oObject;
            return(model);
        }
 public AccountViewModel()
 {
     if (_accountInfo == null)
     {
         _accountInfo = new AccountInfo();
     }
     if (Pagging is null)
     {
         Pagging = new Paggings();
     }
 }
 public async Task <IEnumerable <AccountInfo> > GetAllWithPaggingAsync(Paggings paggings)
 {
     using (var conn = OpenDBConnection())
     {
         StringBuilder sql = new StringBuilder();
         sql.Length = 0;
         sql.AppendLine("SELECT  USER_NO, USER_CD,                ");
         sql.AppendLine("        USER_NAME, FULL_NAME,            ");
         sql.AppendLine("        EMAIL, PHONE,                    ");
         sql.AppendLine("        ADDRESS, ROLE,                   ");
         sql.AppendLine("       TOTAL_COUNT = COUNT(*) OVER()     ");
         sql.AppendLine("FROM dbo.Accounts                        ");
         sql.AppendLine("ORDER BY USER_NO DESC                    ");
         sql.AppendLine("OFFSET (@PageNum-1) * @PageSize ROWS     ");
         sql.AppendLine("FETCH NEXT @PageSize ROWS ONLY           ");
         var param = new
         {
             PageNum  = paggings.PageNum,
             PageSize = paggings.PageSize,
         };
         return(await conn.QueryAsync <AccountInfo>(sql.ToString(), param));
     }
 }