public void KeepAddingPies() { while (true) { AddNewPie(); var pieDao = new PieDao(); var pies = pieDao.GetPies(); Thread.Sleep(TimeSpan.FromSeconds(rand.Next(5, pies.Length < 100 ? 10 : 45))); } }
public Pie[] GetPies(bool?isVegan = null, bool?isGlutenFree = null, string flavor = null, Guid?madeByUserId = null, int?limit = null, bool?randomOrder = null) { var pieDao = new PieDao(); IEnumerable <Pie> pies = pieDao.GetPies(); if (isVegan.HasValue) { pies = pies.Where(p => p.IsVegan == isVegan.Value); } if (isGlutenFree.HasValue) { pies = pies.Where(p => p.IsGlutenFree == isGlutenFree.Value); } if (!string.IsNullOrWhiteSpace(flavor)) { pies = pies.Where(p => p.Flavor.Contains(flavor)); } if (madeByUserId.HasValue) { pies = pies.Where(p => p.MadeByUserIds.Contains(madeByUserId.Value)); } if (randomOrder.HasValue) { var rand = new Random(); pies = pies.OrderBy(p => rand.NextDouble()); } if (limit.HasValue) { pies = pies.Take(limit.Value); } return(pies.ToArray()); }