static void Main(string[] args)
        {
            Console.WriteLine("Proccess Starting...");
            Console.ReadLine();

            var residentFilterParams = new ResidentsFilterParams();

            AuthenticationService.Authorize(new Model.CurrentUserViewModel
            {
                Email    = "*****@*****.**",
                Password = "******"
            });

            var resientsResult = ResidentService.GetResidents(residentFilterParams);

            GenereteObservations(resientsResult.Collection);

            var totalPages = Math.Ceiling((double)resientsResult.TotalCount / residentFilterParams.Take);

            for (var i = 1; i <= totalPages; i++)
            {
                residentFilterParams.Skip = residentFilterParams.Take * (i - 1);

                var residents = ResidentService.GetResidents(residentFilterParams);
                GenereteObservations(residents.Collection);
            }

            Console.WriteLine("Press enter to stop proccess...");
            Console.ReadLine();
        }
        public IActionResult GetResidents([FromBody] ResidentsFilterParams filterParams)
        {
            var userModel = User.GetUserModel();

            filterParams.FacilityId = userModel.FacilityId;
            filterParams.DoctorId   = userModel.DoctorId;

            var residents = _residentService.GetResidentsByParams(filterParams);

            return(Json(JsonResultData.Success(residents)));
        }
        public CollectionResult <ResidentDto> GetResidentsByParams(ResidentsFilterParams filterParams)
        {
            var residents = _unitOfWork.ResidentRepository.GetResidentsByParams(filterParams);

            var result = new CollectionResult <ResidentDto>
            {
                TotalCount = residents.TotalCount,
                Collection = AutoMapper.Mapper.Map <IEnumerable <Resident>, List <ResidentDto> >(residents.Collection)
            };

            return(result);
        }
        private void FillResidentQueryParams(ResidentsFilterParams filterParams)
        {
            var predicate = PredicateBuilder.New <Resident>(true);

            if (!string.IsNullOrEmpty(filterParams.Term))
            {
                predicate = predicate.And(t => t.LastName.Contains(filterParams.Term) || t.FirstName.Contains(filterParams.Term));
            }

            if (filterParams.FacilityId.HasValue)
            {
                predicate = predicate.And(t => t.Department.FacilityId == filterParams.FacilityId.Value);
            }

            if (filterParams.DoctorId.HasValue)
            {
                predicate = predicate.And(t => t.Doctors.Any(d => d.DoctorId == filterParams.DoctorId.Value));
            }

            filterParams.Expression = predicate;
        }
        public CollectionResult <Resident> GetResidentsByParams(ResidentsFilterParams filterParams)
        {
            var residents = GetAllResidents();

            FillResidentQueryParams(filterParams);

            residents = residents.Where(filterParams.Expression);

            var totalCount = residents.Count();

            var result = residents
                         .Skip(filterParams.Skip)
                         .Take(filterParams.Take)
                         .AsNoTracking()
                         .ToList();

            var residentResult = new CollectionResult <Resident>
            {
                Collection = result,
                TotalCount = totalCount
            };

            return(residentResult);
        }
        public IActionResult GetResidentsForIoT([FromBody] ResidentsFilterParams filterParams)
        {
            var residents = _residentService.GetResidentsByParams(filterParams);

            return(Json(residents));
        }
        public static CollectionResult <ResidentDto> GetResidents(ResidentsFilterParams residentsFilterParams)
        {
            var residentResult = HttpClientExtenction.PostDataAndGetResult <ResidentsFilterParams, CollectionResult <ResidentDto> >(residentsFilterParams, string.Concat(_baseResidentDto, _getResidents));

            return(residentResult);
        }