public async Task <IActionResult> Index(int?consumer, string group, string name) { IQueryable <KeyValuePair <int, string> > consumers = from c in _esbModelContext.Consumers orderby c.Name select new KeyValuePair <int, string>(c.ID, c.Name); var groups = from s in _esbModelContext.Services orderby s.GroupName select s.GroupName; var instances = _esbModelContext.Instances.Include(i => i.Client).Include(i => i.Service) .Where(i => string.IsNullOrWhiteSpace(name) || i.Name.Contains(name, StringComparison.OrdinalIgnoreCase)) .Where(i => string.IsNullOrWhiteSpace(group) || i.Service.GroupName.Equals(group, StringComparison.OrdinalIgnoreCase)) .Where(i => consumer == null || i.ClientID == consumer.Value); ViewBag.Consumers = await consumers.ToListAsync(); ViewBag.Groups = await groups.Distinct().ToListAsync(); ViewBag.SelectedConsumer = consumer; ViewBag.SelectedGroup = group; ViewBag.Name = name; return(View(InstanceViewModel.ConvertFrom(await instances.ToListAsync()))); }
public async Task <IActionResult> Index(int serviceId) { var instances = _esbModelContext.Instances.Where(i => i.ServiceID == serviceId) .Include(i => i.Client) .Include(i => i.Service) .Include(i => i.InstanceMapping); ViewBag.ServiceMode = true; return(View(nameof(Index), InstanceViewModel.ConvertFrom(await instances.ToListAsync()))); }