public void RefreshMatrix() { _Items = new Dictionary <int, MatrixItem>(); foreach (IClientAccountAssignment caa in source) { int acctID = caa.AccountID; MatrixItem item; if (!ContainsKey(acctID)) { item = new MatrixItem(new MatrixAccount { AccountID = acctID, Name = caa.AccountName, Number = caa.AccountNumber, Project = GetAccountProject(caa), ShortCode = caa.ShortCode }, ReadOnly); _Items.Add(acctID, item); } item = this[acctID]; MatrixUserAccount ua = new MatrixUserAccount { AccountID = acctID, ClientOrgID = caa.ClientOrgID, DisplayName = GetEmployeeDisplayName(caa), Email = caa.EmployeeEmail }; if (IsAssigned(caa)) { ua.ClientAccountID = caa.EmployeeClientAccountID; ua.WarningMessage = caa.HasDryBox ? "Client has a drybox reserved with this account." : string.Empty; ua.Active = caa.EmployeeClientAccountActive; } MatrixUserHeader uh = _Headers.Where(x => x.ClientOrgID == ua.ClientOrgID).First(); ua.Key = uh.Key; item[ua.ClientOrgID] = ua; } MatrixHtml = new StringBuilder(); string cssAttribute = " class=\"matrix\""; string startTag = string.Format("<table{0}>", cssAttribute); MatrixHtml.AppendLine(startTag); MatrixHtml.AppendLine(HeaderRowHtml.ToString()); foreach (KeyValuePair <int, MatrixItem> kvp in _Items) { MatrixHtml.AppendLine(kvp.Value.MatrixItemHtml.ToString()); } MatrixHtml.AppendLine("</table>"); }
public void RefreshHeaderAndFilter() { _Headers = new List <MatrixUserHeader>(); FilterHtml = new StringBuilder(); FilterHtml.AppendLine("<select>"); //Use the first item's account to get each user name. Each account //should have the same list of users becuase of the way the view works. IClientAccountAssignment first = source.FirstOrDefault(); if (first != null) { int index = 0; int groupNumber = 0; string key = string.Empty; List <IClientAccountAssignment> items = source.Where(x => x.AccountID == first.AccountID).ToList(); foreach (IClientAccountAssignment caa in items) { if (index % GroupSize == 0) { key = "opt-group-" + groupNumber.ToString(); string lname1 = caa.EmployeeLastName; string lname2 = items[Math.Min(index + (GroupSize - 1), items.Count - 1)].EmployeeLastName; string text = string.Format("{0} - {1}", lname1, lname2); FilterHtml.AppendFormat("<option value=\"{0}\">{1}</option>", key, text); groupNumber++; } MatrixUserHeader uh = new MatrixUserHeader { ClientOrgID = caa.ClientOrgID, DisplayName = GetEmployeeDisplayName(caa), Key = key }; _Headers.Add(uh); index++; } } FilterHtml.AppendLine("</select>"); }