public CollectionResult <ResidentDrug> GetResidentDrugsByParams(ResidentDrugsFilterParams parameters)
        {
            var appointments = GetAllResidentDrugs();

            FillResidentDrugsQueryParams(parameters);

            appointments = appointments.Where(parameters.Expression);

            var totalCount = appointments.Count();

            var result = appointments
                         .OrderByDescending(x => x.EndDate)
                         .Skip(parameters.Skip)
                         .Take(parameters.Take)
                         .AsNoTracking()
                         .ToList();

            var appointmentsResult = new CollectionResult <ResidentDrug>
            {
                Collection = result,
                TotalCount = totalCount
            };

            return(appointmentsResult);
        }
        public CollectionResult <ResidentDrugDto> GetResidentDrugsByParams(ResidentDrugsFilterParams filterParams)
        {
            var items = _unitOfWork.ResidentDrugRepository.GetResidentDrugsByParams(filterParams);

            var result = new CollectionResult <ResidentDrugDto>
            {
                TotalCount = items.TotalCount,
                Collection = AutoMapper.Mapper.Map <IEnumerable <ResidentDrug>, List <ResidentDrugDto> >(items.Collection)
            };

            return(result);
        }
        public IActionResult GetResidentDrugs([FromBody] ResidentDrugsFilterParams filterParams)
        {
            var items = _residentDrugService.GetResidentDrugsByParams(filterParams);

            return(Json(JsonResultData.Success(items)));
        }
        private void FillResidentDrugsQueryParams(ResidentDrugsFilterParams filterParams)
        {
            var predicate = PredicateBuilder.New <ResidentDrug>(t => t.ResidentId == filterParams.ResidentId);

            filterParams.Expression = predicate;
        }