예제 #1
0
        public async Task <IActionResult> SearchTrucks()
        {
            var countries = await this.countriesService.GetAllCountriesAsync <AllCountiresSearchTruckViewModel>();

            TruckSearchViewModel inputModel = new TruckSearchViewModel()
            {
                Countries = countries,
            };

            SearchTruckInputModel model = new SearchTruckInputModel()
            {
                InputModel = inputModel,
            };

            string referer = this.Request.Headers["Referer"].ToString();

            model.Referer = referer;

            return(this.View(model));
        }
예제 #2
0
        public async Task GetAllAvaibleTrucksBySearchAsync_WhithNonExistingLoad_ShoulRetunEmptyList()
        {
            var           context    = SteuDbContextInMemoryFactory.InitializeContext();
            TrucksService service    = IntializeLoadService(context);
            var           repository = new EfDeletableEntityRepository <Order>(context);

            await repository.AddAsync(new Order()
            {
                AddressFrom = new Address()
                {
                    Country = new Country()
                    {
                        Name = "Bulgaria"
                    },
                    Town = new Town()
                    {
                        Name = "Sofia"
                    },
                },
                ExpireTime = DateTime.UtcNow.AddDays(7),
                IsDeleted  = false,
                Truck      = new Truck(),
            });

            await context.SaveChangesAsync();

            SearchTruckInputModel model = new SearchTruckInputModel()
            {
                CountryTo = "Bulgaria",
            };

            var actualResult =
                await service.GetAllAvaibleTrucksBySearchAsync <AllAvaibleTrucksBySearchViewModel>(model);

            Assert.Empty(actualResult);
        }
예제 #3
0
        public async Task <IActionResult> SearchTrucks(SearchTruckInputModel model)
        {
            var trucks = await this.trucksService.GetAllAvaibleTrucksBySearchAsync <AllAvaibleTrucksBySearchViewModel>(model);

            return(this.View("SerachTrucksList", trucks));
        }
예제 #4
0
        public async Task <ICollection <TViewModel> > GetAllAvaibleTrucksBySearchAsync <TViewModel>(SearchTruckInputModel model)
        {
            var trucks = await this.orderRepository.All()
                         .Where(x => x.ExpireTime.Date >= DateTime.UtcNow.Date && x.DeletedOn == null && x.Truck != null)
                         .Where(x => (model.CountryFrom == null || x.AddressFrom.Country.Name == model.CountryFrom) &&
                                (model.TownFrom == null || x.AddressFrom.Town.Name == model.TownFrom) &&
                                (model.CountryTo == null || x.AddressTo.Country.Name == model.CountryTo) &&
                                (model.TownTo == null || x.AddressTo.Town.Name == model.TownTo) &&
                                (model.LoadTime == null || x.LoadTime == model.LoadTime) &&
                                (model.MaxLoad == null || x.Truck.MaxLoad >= model.MaxLoad) &&
                                (model.MaxVolume == null || x.Truck.MaxVolume >= model.MaxVolume))
                         .OrderByDescending(x => x.CreatedOn)
                         .To <TViewModel>().ToListAsync();

            return(trucks);
        }