Esempio n. 1
0
        public async Task <IEnumerable <LocationDetailsModel> > GetDetails(int lgaId, string startDate, string endDate)
        {
            List <Enrollee>             maleEnrollees         = new List <Enrollee>();
            List <Enrollee>             femaleEnrollees       = new List <Enrollee>();
            List <Location>             locations             = new List <Location>();
            List <LocationDetailsModel> locationDetailsModels = new List <LocationDetailsModel>();

            if (lgaId == 0)
            {
                locations = _context.Locations.ToList();
            }
            else
            {
                var location = _context.Locations.Find(lgaId);
                locations.Add(location);
            }

            foreach (var item in locations)
            {
                int enrolleesCount = 0;
                LocationDetailsModel detailsModel = new LocationDetailsModel
                {
                    LgaId   = item.Id,
                    LgaName = item.Name
                };
                var hospitals = (List <Hospital>) await _hospitalService.GetHospitalByLocationId(item.Id);

                detailsModel.HospitalCount = hospitals.Count;
                foreach (var hospital in hospitals)
                {
                    enrolleesCount += hospital.Enrollees.Count;
                }
                detailsModel.EnrolleesCount = enrolleesCount;
                maleEnrollees = (List <Enrollee>) await _enrolleeService.FindEnrolleeByGender("male", item.Id, Convert.ToDateTime(startDate), Convert.ToDateTime(endDate));

                detailsModel.MaleEnrolleesCount = maleEnrollees.Count;

                femaleEnrollees = (List <Enrollee>) await _enrolleeService.FindEnrolleeByGender("female", item.Id, Convert.ToDateTime(startDate), Convert.ToDateTime(endDate));

                detailsModel.FemaleEnrolleesCount = femaleEnrollees.Count;

                locationDetailsModels.Add(detailsModel);
            }


            return(locationDetailsModels);
        }
Esempio n. 2
0
        public Task <IEnumerable <Hospital> > GetHospitalByLocationId(int locationId)
        {
            var hospitals = _hospitalService.GetHospitalByLocationId(locationId);

            return(hospitals);
        }