private void RefreshGrid() { var user = _userCache.Get(Context.User.Identity.GetUserId()); var servers = _serverDal.GetByCompany(user.CompanyId).ToSafeList(); ServerGrid.DataSource = string.IsNullOrEmpty(SearchText.Text) ? servers : servers.Where(d => d.ServerName.ToLower().Contains(SearchText.Text.ToLower())).ToList(); ServerGrid.DataBind(); }
private void RefreshGrid() { var deptId = int.Parse(Request.QueryString[QueryStringParameters.DepartmentId]); var dept = _departmentDal.Get(deptId); var userId = Context.User.Identity.GetUserId(); var user = _userCache.Get(userId); if (dept.CompanyId != user.CompanyId) { return; } DepartmentName.Text = $"<h1 style=\"padding-left:10px\">{dept.DepartmentName}</h1>"; var addedServers = dept.Servers?.ToList() ?? new List <Server>(); var notAdded = _serverDal.GetByCompany(dept.CompanyId) ?.Except(addedServers, new ServerComparer(CompareSetting.CompareIds)).ToList() ?? new List <Server>(); if (!string.IsNullOrEmpty(AllSearchText.Text)) { notAdded = notAdded.Where(s => s.ServerName.ToLower().Contains(AllSearchText.Text.ToLower())).ToList(); } if (!string.IsNullOrEmpty(AddedSearchText.Text)) { addedServers = addedServers.Where(s => s.ServerName.ToLower().Contains(AddedSearchText.Text.ToLower())).ToList(); } AllGrid.DataSource = notAdded; AllGrid.DataBind(); AddedGrid.DataSource = addedServers; AddedGrid.DataBind(); }