示例#1
0
        public async Task <IActionResult> SearchLoads()
        {
            var countries = await this.countriesService.GetAllCountriesAsync <AllCountiresSearchLoadViewModel>();

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

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

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

            model.Referer = referer;

            return(this.View(model));
        }
示例#2
0
        public async Task GetAllAvaibleLoadsBySearchAsync_WhithNonExistingLoad_ShoulRetunEmptyList()
        {
            var          context    = SteuDbContextInMemoryFactory.InitializeContext();
            LoadsService 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,
                Load       = new Load(),
            });

            await context.SaveChangesAsync();

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

            var actualResult =
                await service.GetAllAvaibleLoadsBySearchAsync <AllAvaibleLoadsBySearchViewModel>(model);

            Assert.Empty(actualResult);
        }
示例#3
0
        public async Task <IActionResult> SearchLoads(SearchLoadInputModel model)
        {
            var loads = await this.loadsService.GetAllAvaibleLoadsBySearchAsync <AllAvaibleLoadsBySearchViewModel>(model);

            return(this.View("SerachLoadsList", loads));
        }
示例#4
0
        public async Task <ICollection <TViewModel> > GetAllAvaibleLoadsBySearchAsync <TViewModel>(SearchLoadInputModel model)
        {
            var loads = await this.orderRepository.All()
                        .Where(x => x.ExpireTime.Date >= DateTime.UtcNow.Date && x.DeletedOn == null && x.Load != 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.LoadWeight == null || x.Load.Weight <= model.LoadWeight) &&
                               (model.LoadVolume == null || x.Load.Volume <= model.LoadVolume))
                        .OrderByDescending(x => x.CreatedOn)
                        .To <TViewModel>().ToListAsync();

            return(loads);
        }