Пример #1
0
        private void RefreshGrid()
        {
            var userId    = Request.QueryString[QueryStringParameters.UserId];
            var user      = _userDal.Get(userId);
            var companyId = user.Companies.FirstOrDefault()?.CompanyId ?? 0;

            var adminUserId = Context.User.Identity.GetUserId();
            var admin       = _userCache.Get(adminUserId);

            if (companyId != admin.CompanyId)
            {
                return;
            }

            UserName.Text = $"<h1 style=\"padding-left:10px\">{user.UserName}</h1>";

            var addedDepts = user.Departments?.ToList()
                             ?? new List <Department>();

            var notAdded = _departmentDal.GetByCompany(companyId)
                           ?.Except(addedDepts, new DepartmentComparer(CompareSetting.CompareIds)).ToList()
                           ?? new List <Department>();

            if (!string.IsNullOrEmpty(AllSearchText.Text))
            {
                notAdded = notAdded.Where(s => s.DepartmentName.ToLower().Contains(AllSearchText.Text.ToLower())).ToList();
            }

            if (!string.IsNullOrEmpty(AddedSearchText.Text))
            {
                addedDepts = addedDepts.Where(s => s.DepartmentName.ToLower().Contains(AddedSearchText.Text.ToLower())).ToList();
            }

            AllGrid.DataSource = notAdded;
            AllGrid.DataBind();

            AddedGrid.DataSource = addedDepts;
            AddedGrid.DataBind();
        }
Пример #2
0
        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();
        }