public IEnumerable <GoodDTO> Search(string search, FilterModelDTO filterDto) { var filter = Mapper.Map <FilterModelDTO, FilterModel>(filterDto); var goods = _repository.Search(search, filter); var goodsDto = Mapper.Map <IEnumerable <Good>, IEnumerable <GoodDTO> >(goods); return(goodsDto); }
public Func <IEnumerable <Game>, IOrderedEnumerable <Game> > CreateSorting(FilterModelDTO model) { if (model.SortingType != 0) { return(_sorts[model.SortingType]); } return(null); }
/// <summary> /// Filter model is created here instead of in DAL from a db context for demonstration purposes. /// </summary> /// <param name="items">Item list from page model</param> /// <returns>filter model for page model</returns> private FilterModelDTO GetFilterOptionsForPageModel(List <ItemModelDTO> items) { //TODO get these options from the DAL instead of hacking them from the model. var filterModel = new FilterModelDTO() { OrganizationOptions = items.Select(x => x.Organization).Distinct().ToList(), POCNameOptions = items.Select(x => x.POCName).Distinct().ToList(), DateBeginOptions = items.Select(x => x.DateBegin).Distinct().ToList() }; return(filterModel); }
public ActionResult GoodsSearch(string search, FilterModelDTO filterDto) { var goods = _goodLogic.Search(search, filterDto); var goodViews = _adminHelper.GoodDtoListToGoodAdminViewList(goods); if (goodViews.Any()) { return(PartialView(goodViews)); } return(PartialView("SearchNull")); }
public override void FilterRegister(FilterModelDTO filterModel) { var priceRange = new[] { filterModel.PriceRangeFrom, filterModel.PriceRangeTo }; var filters = new FilterContext(filterModel.GenresName, filterModel.PlatformTypesName, filterModel.PublishersName, priceRange, filterModel.PartOfName); var sort = new SortingResolver(); if (filterModel.GenresName.Any()) { Register(filters.FilterDictionary[FiltersEnum.GenreFilter]); } if (filterModel.PlatformTypesName.Any()) { Register(filters.FilterDictionary[FiltersEnum.PlatformFilter]); } if (filterModel.PublishersName.Any()) { Register(filters.FilterDictionary[FiltersEnum.PublisherFilter]); } if (filterModel.PriceRangeFrom != 0 || filterModel.PriceRangeTo != 0) { Register(filters.FilterDictionary[FiltersEnum.PriceRange]); } if (filterModel.PublicationTime != 0) { Register(filters.FilterDictionary[filterModel.PublicationTime]); } if (filterModel.PartOfName != null) { Register(filters.FilterDictionary[FiltersEnum.SearchByName]); } SortRegister(sort.CreateSorting(filterModel)); }
public ActionResult GoodsSearch(string search, FilterModelDTO filterDto, int page = 1) { var goods = _goodLogic.Search(search, filterDto); var goodViews = Mapper.Map <IEnumerable <GoodDTO>, IEnumerable <GoodViewModel> >(goods); var id = User.Identity.GetUserId(); var user = _clientLogic.Get(id); if (user != null) { foreach (var goodView in goodViews) { var dis = (100 - user.Discount) / 100; goodView.PriceWithDiscount = goodView.PriceSale * (decimal)dis; } } //todo: refactor -take goods grop _goodLogic int pageSize = 5; // количество объектов на страницу IEnumerable <GoodViewModel> goodssPerPages = goodViews.Skip((page - 1) * pageSize).Take(pageSize); PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = goodViews.Count() }; GoodListViewModel ivm = new GoodListViewModel { PageInfo = pageInfo, Goods = goodssPerPages }; if (ivm.Goods.Any()) { return(PartialView(goodViews.ToPagedList(page, pageSize))); } return(PartialView("SearchNull")); }
public abstract void FilterRegister(FilterModelDTO filterModelDto);