private IEnumerable <JobOffer> FilterOffers(SearchOfferViewModel model)
        {
            IEnumerable <JobOffer> offers = this.FilterBySector(model.Sectors);

            if (offers != null && model.Town != null)
            {
                offers = offers.Where(o => o.TownId == model.Town);
            }

            if (offers != null && model.Word != null)
            {
                string word = model.Word.ToLower();
                offers = offers.Where(o => o.Title.ToLower().Contains(word) || o.Description.ToLower().Contains(word) ||
                                      o.BusinessSector.Name.ToLower().Contains(word) || o.Company.CompanyName.ToLower().Contains(word));
            }

            if (offers != null && model.IsFullTime != null)
            {
                offers = offers.Where(o => o.IsFullTime == model.IsFullTime);
            }

            if (offers != null && model.IsPermanent != null)
            {
                offers = offers.Where(o => o.IsPermanent == model.IsPermanent);
            }

            return(offers);
        }
Exemplo n.º 2
0
        public ActionResult New()
        {
            var contractorOfferTypes = _context.ContractorOfferTypes.ToList();
            var viewModel            = new SearchOfferViewModel()
            {
                ContractorOffer      = new ContractorOffer(),
                ContractorOfferTypes = contractorOfferTypes
            };

            return(View("NewDetailsOffer", viewModel));
        }
        public void Check_view()
        {
            var model = new SearchOfferViewModel();
            var view  = (SearchOfferView)Bind(model);

            var offer = session.Query <Offer>().First();

            model.SearchBehavior.SearchText.Value = offer.ProductSynonym.Slice(3);
            model.SearchBehavior.Search();

            ForceBinding(view);
        }
        private IEnumerable <SearchResultOfferViewModel> GetResults(SearchOfferViewModel lastSearch)
        {
            int offersCount = 0;

            IEnumerable <SearchResultOfferViewModel> offers = this.FilterOffers(lastSearch).AsQueryable().Include("Company").Include("Town")
                                                              .Select(SearchResultOfferViewModel.FromJobOffer).OrderByDescending(o => o.DateCreated);

            offersCount = offers.Count();

            this.TempData["OffersCount"] = offersCount;
            return(offers);
        }
Exemplo n.º 5
0
        public void Search(TextCompositionEventArgs args)
        {
            if (!CanShowPrice)
            {
                return;
            }

            var model = new SearchOfferViewModel();

            model.SearchBehavior.SearchText.Value = args.Text;
            Shell.Navigate(model);
        }
        public void Export()
        {
            user.Permissions.Clear();
            var model = new SearchOfferViewModel();

            Activate(model);
            Assert.IsFalse(model.CanExport);

            model.User.Permissions.Add(new Permission("FPL"));
            model = new SearchOfferViewModel();
            Activate(model);
            Assert.IsTrue(model.CanExport);
        }
Exemplo n.º 7
0
        public ActionResult Details(int id)
        {
            var contrctorOffer = _context.ContractorOffer.Include(co => co.Contractor)
                                 .Include(co => co.ContractorOfferType)
                                 .Include(co => co.ContractorEmployee).SingleOrDefault(co => co.Id == id);

            var contractorOfferTypes = _context.ContractorOfferTypes.ToList();

            var searchOfferViewModel = new SearchOfferViewModel()
            {
                ContractorOfferTypes = contractorOfferTypes,
                ContractorOffer      = contrctorOffer
            };

            return(View("NewDetailsOffer", searchOfferViewModel));
        }
        public ActionResult OfferSearchResults(int?page, int[] sectors, int?town, string word, bool isPermanent, bool isTemporary, bool isFullTime, bool isPartTime)
        {
            SearchOfferViewModel search = new SearchOfferViewModel();

            search.Page        = page ?? 1;
            search.Sectors     = sectors;
            search.Town        = town;
            search.Word        = word;
            search.IsFullTime  = isFullTime.MapBools(isPartTime);
            search.IsPermanent = isPermanent.MapBools(isTemporary);
            IEnumerable <SearchResultOfferViewModel> offers = this.GetResults(search);

            this.TempData["Town"]        = search.Town;
            this.TempData["Word"]        = search.Word;
            this.TempData["Sectors"]     = sectors;
            this.TempData["IsFullTime"]  = isFullTime;
            this.TempData["IsPermanent"] = isPermanent;

            return(this.View(offers.ToPagedList((int)search.Page, OffersPerPage)));
        }
Exemplo n.º 9
0
        // GET: ContractorOffer
        //public ViewResult Index()
        //{
        //    var contractorOffers = _context.ContractorOffer.Include(n => n.Contractor)
        //                              .Include(n => n.ContractorEmployee)
        //                              .Include(t => t.ContractorOfferType).ToList();

        //    var searchOfferViewModel = new SearchOfferViewModel()
        //    {
        //        ContractorOffers = contractorOffers,
        //        Contractor = new Contractor(),
        //        ContractorEmployee = new ContractorEmployee()

        //    };
        //    return View(searchOfferViewModel);
        //}

        public ViewResult Index(ContractorOffer contractorOffer)
        {
            var contractorOffers = _context.ContractorOffer.Where(co => co.IsActive == true).Include(co => co.Contractor)
                                   .Include(co => co.ContractorEmployee)
                                   .Include(co => co.ContractorOfferType).ToList();

            if (contractorOffer.Contractor != null)
            {
                if (!String.IsNullOrEmpty(contractorOffer.Contractor.Name))
                {
                    contractorOffers = contractorOffers.Where(co => co.Contractor.Name == contractorOffer.Contractor.Name).ToList();
                }
            }
            if (contractorOffer.ContractorEmployee != null)
            {
                if (!String.IsNullOrEmpty(contractorOffer.ContractorEmployee.FullName))
                {
                    contractorOffers = contractorOffers.Where(co => co.ContractorEmployee.FullName == contractorOffer.ContractorEmployee.FullName).ToList();
                }
            }

            if (contractorOffer.ContractorOfferTypeId.HasValue)
            {
                contractorOffers = contractorOffers.Where(co => co.ContractorOfferTypeId == contractorOffer.ContractorOfferTypeId).ToList();
            }



            var contractorOfferTypes = _context.ContractorOfferTypes.ToList();

            var searchOfferViewModel = new SearchOfferViewModel()
            {
                ContractorOffers     = contractorOffers,
                Contractor           = new Contractor(),
                ContractorEmployee   = new ContractorEmployee(),
                ContractorOffer      = new ContractorOffer(),
                ContractorOfferTypes = contractorOfferTypes
            };

            return(View(searchOfferViewModel));
        }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            ProductInfo = new ProductInfo(this, CurrentOffer);
            Doc.Value   = Session.Query <OrderReject>().First(r => r.DownloadId == id);
            var waybill = Session.Query <Waybill>().First(r => r.Id == id);

            if (waybill.IsNew)
            {
                waybill.IsNew = false;
                if (Shell.NewDocsCount.Value > 0)
                {
                    Shell.NewDocsCount.Value--;
                }
            }
            if (Doc.Value.Supplier == null)
            {
                DisplaySupplierName = waybill.UserSupplierName;
            }
            else
            {
                DisplaySupplierName = Doc.Value.Supplier.FullName;
            }

            Lines.Value = Doc.Value.Lines.OrderBy(l => l.Product).ToList();

            CurrentLine
            .Throttle(Consts.ScrollLoadTimeout, UiScheduler)
            .Select(v => RxQuery(s => {
                if (CurrentLine.Value == null)
                {
                    return(Enumerable.Empty <Offer>().ToList());
                }

                var productId = CurrentLine.Value.ProductId;
                if (productId != null)
                {
                    var offers = s.Query <Offer>().Where(o => o.ProductId == productId)
                                 .Fetch(o => o.Price)
                                 .ToList();
                    return(offers.OrderBy(c => c.ResultCost).ToList());
                }
                else
                {
                    var offers = SearchOfferViewModel.QueryByFullText(s, CurrentLine.Value.Product);
                    //выделяем цветом предложения которые относятся к одному товару
                    uint lastCatalogId = 0;
                    bool lastGroup     = true;
                    foreach (var offer in offers)
                    {
                        if (offer.CatalogId != lastCatalogId)
                        {
                            lastCatalogId = offer.CatalogId;
                            lastGroup     = !lastGroup;
                        }
                        offer.IsGrouped = lastGroup;
                    }
                    return(offers);
                }
            }))
            .Switch()
            //будь бдителен CalculateRetailCost и LoadOrderItems может вызвать обращение к базе если данные еще не загружены
            //тк синхронизация не производится загрузка должна выполняться в основной нитке
            .Do(v => {
                LoadOrderItems(v);
                Calculate(v);
            })
            .Subscribe(Offers, CloseCancellation.Token);
        }
Exemplo n.º 11
0
        public async Task <ActionResult> OfferSearch(SearchOfferViewModel search)
        {
            Sort sort = (Sort)Enum.Parse(typeof(Sort), search.SortBy, true);


            List <Offer> offers = await offerService.GetOffersAsync(o => o.Game.Value == search.Game, i => i.Game, i => i.UserProfile);

            if (search.PersonalAccount)
            {
                offers = offers.Where(o => o.PersonalAccount).ToList();
            }

            if (search.IsBanned)
            {
                offers = offers.Where(o => o.IsBanned).ToList();
            }

            //offers = offers.Where(o => search.IsBanned && o.IsBanned).ToList();
            //offers = offers.Where(o => search.Game == o.Game.Value).ToList();

            if (offers.Any() && search.PriceFrom == 0)
            {
                search.PriceFrom = offers.Min(o => o.Price);
            }
            if (offers.Any() && search.PriceTo == 0)
            {
                search.PriceTo = offers.Max(o => o.Price);
            }
            offers = offers.Where(o => search.PriceFrom <= o.Price && search.PriceTo >= o.Price).ToList();
            switch (sort)
            {
            case Sort.BestSeller:
                offers = offers.OrderBy(o => o.UserProfile.Rating).ToList();
                break;

            case Sort.Newest:
                offers = offers.OrderBy(o => o.CreatedDate).ToList();
                break;

            case Sort.PriceAsc:
                offers = offers.OrderBy(o => o.Price).ToList();
                break;

            case Sort.PriceDesc:
                offers = offers.OrderByDescending(o => o.Price).ToList();
                break;

            default:
                offers = offers.OrderBy(o => o.UserProfile.Rating).ToList();
                break;
            }
            var modelOffers = Mapper.Map <IEnumerable <Offer>, IEnumerable <OfferViewModel> >(offers);

            var model = new OfferListViewModel()
            {
                Offers   = modelOffers.Skip((search.Page - 1) * pageSize).Take(pageSize).ToList(),
                PageInfo = new PageInfoViewModel
                {
                    PageNumber = search.Page,
                    PageSize   = pageSize,
                    TotalItems = modelOffers.Count()
                }
            };



            foreach (var item in model.SortBy)
            {
                if (item.Value == search.SortBy.ToString())
                {
                    item.Selected = true;
                }
                else
                {
                    item.Selected = false;
                }
            }
            return(PartialView("_OfferTable", model));
        }