Esempio n. 1
0
        private static IQueryable <LocationEntity> ApplyFiltering(IQueryable <LocationEntity> queryable,
                                                                  GetLocationsCommand command)
        {
            queryable = queryable.Where(x => x.AssetId == command.AssetId);

            queryable = queryable.Where(x => x.DateTime > command.Model.StartDate && x.DateTime < command.Model.EndDate);

            if (command.Model.StartSpeed.HasValue && command.Model.EndSpeed.HasValue)
            {
                queryable = queryable.Where(x => x.Speed >= command.Model.StartSpeed && x.Speed <= command.Model.EndSpeed);
            }
            else if (command.Model.StartSpeed.HasValue)
            {
                queryable = queryable.Where(x => x.Speed >= command.Model.StartSpeed);
            }
            else if (command.Model.EndSpeed.HasValue)
            {
                queryable = queryable.Where(x => x.Speed <= command.Model.EndSpeed);
            }

            if (command.Model.StartAltitude.HasValue && command.Model.EndAltitude.HasValue)
            {
                queryable = queryable.Where(x => x.Altitude >= command.Model.StartAltitude && x.Altitude <= command.Model.EndAltitude);
            }
            else if (command.Model.StartAltitude.HasValue)
            {
                queryable = queryable.Where(x => x.Altitude >= command.Model.StartAltitude);
            }
            else if (command.Model.EndAltitude.HasValue)
            {
                queryable = queryable.Where(x => x.Altitude <= command.Model.EndAltitude);
            }

            return(queryable);
        }
        public void GetLocationsCommandTest()
        {
            GetLocationsCommand GetLocationsCommand = CommandFactory.GetLocationsCommand();

            GetLocationsCommand.Execute();
            Assert.NotNull(GetLocationsCommand.GetResult());
        }
Esempio n. 3
0
        public ActionResult <IEnumerable <LocationDTO> > Get()
        {
            LocationMapper      locationMapper      = MapperFactory.createLocationMapper();
            GetLocationsCommand commandGetLocations = CommandFactory.GetLocationsCommand();

            commandGetLocations.Execute();
            var result = commandGetLocations.GetResult();

            _logger?.LogInformation($"Obtenida las Location  por pais exitosamente");
            return(locationMapper.CreateDTOList(result));
        }
Esempio n. 4
0
        public override async Task <IEnumerable <LocationModel> > Handle(GetLocationsCommand command)
        {
            IQueryable <LocationEntity> queryable = repository.GetEntities <LocationEntity>();

            queryable = ApplyFiltering(queryable, command);

            queryable = queryable
                        .OrderByDescending(x => x.DateTime)
                        .Take(100000);


            List <LocationEntity> locations = await queryable.ToListAsync();

            List <LocationModel> mapped = locations.Select(mapper.Map <LocationEntity, LocationModel>).ToList();

            return(mapped);
        }