Exemple #1
0
        public async Task <IActionResult> getPatientPrescription([FromQuery] PrescriptionListFilterModel prescriptionListFilterModel)
        {
            try
            {
                if (_context.Patient.Any(p => p.Patientid.Contains(prescriptionListFilterModel.PatientId)))
                {
                    var prescriptionListWithCount = await _pharmacyManagementRepository.getPatientPrescriptionsList(prescriptionListFilterModel);

                    var prescriptionList = new PagedList <PharmacyManagementDTO>(prescriptionListWithCount.PrescriptionList, prescriptionListWithCount.Count, prescriptionListFilterModel.PageNumber, prescriptionListFilterModel.PageSize);

                    Response.Headers.Add("TotalCount", JsonConvert.SerializeObject(prescriptionList.TotalCount));
                    Response.Headers.Add("PageSize", JsonConvert.SerializeObject(prescriptionList.PageSize));
                    Response.Headers.Add("CurrentPage", JsonConvert.SerializeObject(prescriptionList.CurrentPage));
                    Response.Headers.Add("TotalPages", JsonConvert.SerializeObject(prescriptionList.TotalPages));
                    Response.Headers.Add("HasNext", JsonConvert.SerializeObject(prescriptionList.HasNext));
                    Response.Headers.Add("HasPrevious", JsonConvert.SerializeObject(prescriptionList.HasPrevious));

                    return(Ok(prescriptionList));
                }
                else
                {
                    return(BadRequest("invalid patientid"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetPrescriptionList([FromQuery] PrescriptionListFilterModel prescriptionListFilterModel)
        {
            try
            {
                //var count = _context.ConsultationPrescription.Count();
                var prescriptionListWithCount = await _pharmacyManagementRepository.getConsultationPrescriptionsList(prescriptionListFilterModel);

                var prescriptionList = new PagedList <PharmacyManagementDTO>(prescriptionListWithCount.PrescriptionList, prescriptionListWithCount.Count, prescriptionListFilterModel.PageNumber, prescriptionListFilterModel.PageSize);

                Response.Headers.Add("TotalCount", JsonConvert.SerializeObject(prescriptionList.TotalCount));
                Response.Headers.Add("PageSize", JsonConvert.SerializeObject(prescriptionList.PageSize));
                Response.Headers.Add("CurrentPage", JsonConvert.SerializeObject(prescriptionList.CurrentPage));
                Response.Headers.Add("TotalPages", JsonConvert.SerializeObject(prescriptionList.TotalPages));
                Response.Headers.Add("HasNext", JsonConvert.SerializeObject(prescriptionList.HasNext));
                Response.Headers.Add("HasPrevious", JsonConvert.SerializeObject(prescriptionList.HasPrevious));
                return(Ok(prescriptionList));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(BadRequest());
            }
        }