public IActionResult Store(string FromPrice, string TopPrice, string SelectedStreet) { var list = from s in context.Appartments select s; if (TopPrice != null || FromPrice != null) { if (TopPrice == null) { list = list.Where(x => x.Price > int.Parse(FromPrice)); } else if (FromPrice == null) { list = list.Where(x => x.Price < int.Parse(TopPrice)); } else { list = list.Where(x => x.Price > int.Parse(FromPrice) && x.Price < int.Parse(TopPrice)); } } if (!String.IsNullOrEmpty(SelectedStreet)) { list = list.Where(x => x.Adress.ToLower().Contains(SelectedStreet.ToLower())); } AppartmentsListModel model = new AppartmentsListModel(list.ToList()); return(View(model)); }
public IActionResult Index() { ViewData["Message"] = "Your application description page."; var list = (from s in context.Appartments select s).ToList(); AppartmentsListModel model = new AppartmentsListModel(list); return(View(model)); }
public IActionResult Manage() { var list = from s in context.Appartments select s; if (!User.IsInRole("Admin")) { list = list.Where(x => x.UserEmail == HttpContext.User.Identity.Name); } AppartmentsListModel model = new AppartmentsListModel(list.ToList()); return(View(model)); }