예제 #1
0
        public async Task <Dictionary <ServiceDictionaryKey, object> > TryListPatients(HttpRequest request)
        {
            Dictionary <ServiceDictionaryKey, object> dictionary = new Dictionary <ServiceDictionaryKey, object>();

            try
            {
                int amountRequested = _queryHelper.ExtractIntegerFromRequestQuery("count", request);

                List <Patient> patients = await _patientRepository.List(amountRequested);

                PatientReturnModel[] returnModels = new PatientReturnModel[patients.Count];

                for (int i = 0; i < patients.Count; i++)
                {
                    returnModels[i] = new PatientReturnModel(patients[i]);
                }

                dynamic data = _messageSerializer.Serialize(returnModels);
                dictionary.Add(ServiceDictionaryKey.VALUE, data);
            }
            catch (Exception ex)
            {
                dictionary.AddErrorMessage(ServiceDictionaryKey.ERROR, ex, FeedbackHandler);
            }

            return(dictionary);
        }