public async Task <ActionResult> GetPatient([FromQuery] SieveModel sieveModel) { // return all patients if (sieveModel.PageSize == null && sieveModel.Page == null) { try { _logger.LogInformation($"Get all Patients info from db"); var allPatients = await _patientManager.GetAllPatients(); var allPatientsViewModel = _mapper.Map <List <PatientViewModel> >(allPatients); return(Ok(JObject.FromObject(new { patients = allPatientsViewModel }))); } catch (Exception e) { throw new HttpStatusCodeException(500, "Error happend when process get all patients request." + e.Message); } } try { var pagedModel = await _patientManager.GetPagedPatientAsync(sieveModel); _logger.LogInformation($"Get paged patient result from DB PageSize {sieveModel.PageSize}, PageNo: {sieveModel.Page}"); var reuslt = new PagedResult <PatientViewModel>() { PageNumber = pagedModel.PageNumber, PageSize = pagedModel.PageSize, TotalNumberOfPages = pagedModel.TotalNumberOfPages, TotalNumberOfRecords = pagedModel.TotalNumberOfRecords, Results = _mapper.Map <List <PatientViewModel> >(pagedModel.Results) }; return(Ok(reuslt)); } catch (Exception e) { throw new HttpStatusCodeException(500, "Error happend when get paged result request." + e.Message); } }