Пример #1
0
 /// <summary>
 /// 1- Check for consistency and set default value if not supplied by caller.
 /// 2- Call repo.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="pageModel"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public async Task <PagingParameterOutModel <HRBirdMainOutput> > GetMainRecordsAsync(HRBirdMainInput query, PagingParameterInModel pageModel, HRSortingParamModel orderBy)
 {
     //1-
     if (_repo == null)
     {
         throw new Exception("repository not set.");
     }
     if (query == null)
     {
         query = GetDefaultMainInput();
     }
     if (pageModel == null)
     {
         pageModel = GetDefaultMainPagination();
     }
     //2-
     using (var taskRepo = _repo.GetMainRecordsAsync(query, pageModel, orderBy))
     {
         await taskRepo;
         if (taskRepo.IsCompletedSuccessfully)
         {
             return(taskRepo.Result);
         }
         else
         {
             throw new Exception("Something goes wrong in _repo.GetMainRecordsAsync");
         }
     }
 }