//GetByCriterias
 public IEnumerable<AuctionShort> GetByCriterias(AuctionFilterParams filter)
 {
     int? totalrecords = 0;
     var pageindex = (filter.page > 0) ? filter.page - 1 : 0;
     var ash = (!filter.SeachType.HasValue)
         ? GetByCriterias(filter.Lot, filter.Title, (int) filter.Sortby,
             filter.Orderby == Consts.OrderByValues.descending, filter.Event_ID.Value, pageindex, filter.PageSize,
             out totalrecords)
         : GetByCriterias(filter, (int) filter.Sortby, filter.Orderby == Consts.OrderByValues.descending,
             pageindex, filter.PageSize, out totalrecords);
     return new PagedList<AuctionShort>(ash, pageindex, filter.PageSize,
         totalrecords.HasValue ? totalrecords.Value : 0);
 }
 //GetAuctionListForSeller
 public IEnumerable<AuctionShort> GetAuctionListForSeller(AuctionFilterParams filter, long user_id)
 {
     int? totalrecords = 0;
     var pageindex = (filter.page > 0) ? filter.page - 1 : 0;
     dataContext.CommandTimeout = 600000;
     var ash =
         (from p in
             dataContext.spAuction_View_Search(filter.Event_ID, filter.Type == "l" ? filter.Lot : String.Empty,
                 filter.Type == "t" || filter.Type == "td" ? filter.Title : String.Empty,
                 filter.Type == "d" || filter.Type == "td" ? filter.Description : String.Empty,
                 filter.SelectedCategory, user_id, (int) filter.Sortby - 1, (byte) filter.Orderby == 2, pageindex,
                 filter.PageSize, ref totalrecords)
             select new AuctionShort
             {
                 Bids = p.Bids.GetValueOrDefault(0),
                 CurrentBid = p.CurrentBid.GetValueOrDefault(0),
                 Estimate = p.Estimate,
                 IsBold = p.IsBold.GetValueOrDefault(false),
                 IsFeatured = p.IsFeatured.GetValueOrDefault(false),
                 IsUnsoldOrPulledOut =
                     p.IsUnsold.GetValueOrDefault(false) || p.IsPulledOut.GetValueOrDefault(false),
                 LinkParams =
                     new LinkParams
                     {
                         ID = p.Auction_ID.GetValueOrDefault(0),
                         EventTitle = p.EventTitle,
                         MainCategoryTitle = p.MainCategoryTitle,
                         CategoryTitle = p.CategoryTitle
                     },
                 Lot = p.Lot.HasValue ? p.Lot.Value : (short) 0,
                 Price = p.Price.GetValueOrDefault(0),
                 PriceRealized = p.PriceRealized.GetValueOrDefault(0),
                 PulledOut = p.IsPulledOut.GetValueOrDefault(false),
                 Status = p.AuctionStatus.GetValueOrDefault(0),
                 ThumbnailPath = p.ThumbnailPath,
                 Title = p.Title,
                 UnsoldOrPulledOut = p.IsUnsold.GetValueOrDefault(false) ? "UNSOLD" : "WITHDRAWN"
             });
     return new PagedList<AuctionShort>(ash.ToList(), pageindex, filter.PageSize,
         totalrecords.HasValue ? totalrecords.Value : 0);
 }
 public ActionResult pConsignedItemsPast(long user_id, AuctionFilterParams param, int page, int viewmode, int imageviewmode)
 {
   ViewData["IsPastGrid"] = true;
   return View("pAuctionGrid", pConsignedItems(param, user_id));
 }
        //GetByCriterias (advanced)
        private List<AuctionShort> GetByCriterias(AuctionFilterParams filter, int sortby, bool ordrby, int pageindex,
            int pagesize, out int? totalrecord)
        {
            filter.Title = String.IsNullOrEmpty(filter.Title) ? String.Empty : filter.Title.Replace(" ", "%");
            filter.Description = String.IsNullOrEmpty(filter.Description)
                ? String.Empty
                : filter.Description.Replace(" ", "%");
            var dco = new DataCacheObject(DataCacheType.RESOURCE, DataCacheRegions.AUCTIONLISTS, "GETBYCRITERIAS",
                new object[]
                {
                    filter.Event_ID, filter.Type == "l" ? filter.Lot : String.Empty,
                    filter.Type == "t" || filter.Type == "td" ? filter.Title : String.Empty,
                    filter.Type == "d" || filter.Type == "td" ? filter.Description : String.Empty,
                    filter.SelectedCategory, -1, sortby - 1, ordrby,
                    pageindex, pagesize
                }, CachingExpirationTime.Seconds_30);

            var result = CacheRepository.Get(dco) as TableViewResult;
            if (result != null && result.TotalRecords > 0)
            {
                totalrecord = result.TotalRecords;
                return result.Records;
            }
            result = new TableViewResult();
            totalrecord = 0;
            dataContext.CommandTimeout = 600000;
            result.Records =
                (from p in
                    dataContext.spAuction_View_Search(filter.Event_ID, filter.Type == "l" ? filter.Lot : String.Empty,
                        filter.Type == "t" || filter.Type == "td" ? filter.Title : String.Empty,
                        filter.Type == "d" || filter.Type == "td" ? filter.Description : String.Empty,
                        filter.SelectedCategory, -1, sortby - 1, ordrby, pageindex, pagesize, ref totalrecord)
                    select new AuctionShort
                    {
                        Bids = p.Bids.GetValueOrDefault(0),
                        CurrentBid = p.CurrentBid.GetValueOrDefault(0),
                        Estimate = p.Estimate,
                        IsBold = p.IsBold.GetValueOrDefault(false),
                        IsFeatured = p.IsFeatured.GetValueOrDefault(false),
                        IsUnsoldOrPulledOut =
                            p.IsUnsold.GetValueOrDefault(false) || p.IsPulledOut.GetValueOrDefault(false),
                        LinkParams =
                            new LinkParams
                            {
                                ID = p.Auction_ID.GetValueOrDefault(0),
                                EventTitle = p.EventTitle,
                                MainCategoryTitle = p.MainCategoryTitle,
                                CategoryTitle = p.CategoryTitle
                            },
                        Lot = p.Lot.HasValue ? p.Lot.Value : (short) 0,
                        Price = p.Price.GetValueOrDefault(0),
                        PriceRealized = p.PriceRealized.GetValueOrDefault(0),
                        PulledOut = p.IsPulledOut.GetValueOrDefault(false),
                        Status = p.AuctionStatus.GetValueOrDefault(0),
                        ThumbnailPath = p.ThumbnailPath,
                        Title = p.Title,
                        UnsoldOrPulledOut = p.IsUnsold.GetValueOrDefault(false) ? "UNSOLD" : "WITHDRAWN"
                    }).ToList();
            result.TotalRecords = totalrecord.GetValueOrDefault(0);
            if (result.TotalRecords > 0)
            {
                dco.Data = result;
                CacheRepository.Add(dco);
            }
            return result.Records;
        }
 //pConsignedItems
 private object pConsignedItems(AuctionFilterParams param, long user_id)
 {
   SetFilterParams(param);
   ViewData["PageActionPath"] = "ConsignedItems";
   ViewData["IsUserRegisteredForEvent"] = Consts.IsAllUsersCanSeeBids;
   ViewData["IsShownOpenBidOne"] = Consts.IsShownOpenBidOne;
   return AuctionRepository.GetAuctionListForSeller(param, user_id);
 }
 public ActionResult pConsignedItemsSearch(long user_id, AuctionFilterParams param)
 {
   List<Event> evnts = EventRepository.GetConsingedEvents(AppHelper.CurrentUser.ID);
   List<SelectListItem> sl = new List<SelectListItem>();
   sl.Add(new SelectListItem() { Selected = !param.Event_ID.HasValue || -1 == param.Event_ID.Value, Value = "-1", Text = "Search All Auctions" });
   foreach (Event evnt in evnts)
     sl.Add(new SelectListItem() { Selected = param.Event_ID.HasValue && evnt.ID == param.Event_ID.Value, Text = evnt.Title, Value = evnt.ID.ToString() });
   ViewData["AllEvents"] = sl;
   return View("pConsignedItemsSearch", param);
 }
 public ActionResult pSearchResultPast(bool iscurrent, AuctionFilterParams param, int page, int viewmode, int imageviewmode)
 {
   ViewData["IsPastGrid"] = true;
   return View("pAuctionGrid", pSearch(param));
 }
 //pSearch
 private object pSearch(AuctionFilterParams param)
 {
   SetFilterParams(param);
   ViewData["PageActionPath"] = "SearchResult";
   ViewData["IsUserRegisteredForEvent"] = Consts.IsAllUsersCanSeeBids;
   ViewData["IsShownOpenBidOne"] = Consts.IsShownOpenBidOne;
   return AuctionRepository.GetByCriterias(param);
 }        
 [ChildActionOnly] //, ActionOutputCache(Consts.CachingTime_01day)
 public ActionResult pAdvancedSearch(long eventid, AuctionFilterParams param)
 {
   List<IEvent> evnts = new List<IEvent>(EventRepository.GetPastedEventsList());
   if (evnts.Count > 0 && evnts[0].ID != eventid) evnts.Insert(0, EventRepository.GetEventByID(eventid));
   
   List<SelectListItem> sl = new List<SelectListItem>();
   sl.Add(new SelectListItem() { Selected = !param.Event_ID.HasValue || -1 == param.Event_ID.Value, Value = "-1", Text = "Search All Auctions" });
   foreach (Event evnt in evnts)
     sl.Add(new SelectListItem() { Selected = param.Event_ID.HasValue && evnt.ID == param.Event_ID.Value, Text = evnt.Title, Value = evnt.ID.ToString() });
   ViewData["AllEvents"] = sl;
   
   List<SelectListItem> cl = new List<SelectListItem>();
   cl.Add(new SelectListItem() { Selected = !param.SelectedCategory.HasValue || -1 == param.SelectedCategory.Value, Value = "-1", Text = "All Categories" });
   foreach (IdTitle item in CategoryRepository.GetListForCategory(eventid))
     cl.Add(new SelectListItem() { Selected = param.SelectedCategory.HasValue && param.SelectedCategory.Value==item.ID, Text = item.Title, Value = item.ID.ToString() });
   ViewData["CategoriesList"] = cl;
   return View("pAdvancedSearch", param);
 }