Example #1
0
        private List <Lot> SelectLots(SortBy sortBy, List <Lot> Lots)
        {
            var lots = Lots.Where(i => i.IsAvailable && i.EndAt > DateTime.UtcNow);

            lots = sortBy switch
            {
                SortBy.Date => lots.OrderBy(i => i.EndAt),
                SortBy.DistinctDate => lots.OrderByDescending(i => i.EndAt),
                SortBy.Name => lots.OrderBy(i => i.Title),
                SortBy.DistinctName => lots.OrderByDescending(i => i.Title),
                SortBy.Goal => lots.OrderBy(i => i.MinPrice),
                SortBy.Funded => lots.OrderBy(i => i.Rates.OrderByDescending(c => c.CreatedAt).FirstOrDefault().Amount),
                _ => lots
            };

            return(lots.ToList());
        }