public static string GetRecipientCount(int recipientTypeId, int geographyId) { int personCount = 0; AuthenticationData authData = GetAuthenticationDataAndCulture(); Geography geography = Geography.FromIdentity(geographyId); Geographies geoTree = geography.GetTree(); Organizations orgTree = authData.CurrentOrganization.GetTree(); switch (recipientTypeId) { case 0: // "Select one" personCount = 0; break; case 1: // Regulars personCount = orgTree.GetMemberCountForGeographies(geoTree); break; case 2: // Agents personCount = Activists.GetCountForGeography(geography); break; // TODO: Dynamic membership types case 101: // Officers personCount = orgTree.GetRoleHolderCountForGeographies(geoTree); break; case 102: // Volunteers personCount = 0; // TODO break; default: throw new NotImplementedException(); } string result; string[] resources = Resources.Pages.Comms.SendMassMessage_RecipientCount.Split('|'); switch (personCount) { case 0: result = resources[0]; break; case 1: result = resources[1]; break; default: result = String.Format(resources[2], personCount); break; } return(result); }
private void UpdateSmsCosts() { this.PanelSmsText.Visible = this.CheckSms.Checked; if (this.CheckSms.Checked) { Geography selectedGeo = this.GeographyTree.SelectedGeography; int activistCount = Activists.GetCountForGeography(selectedGeo); ResetSmsCosts(selectedGeo, activistCount); } else { this.LabelSmsCost.Text = "0.00"; this.LabelBudget.Text = "None"; } }
private void UpdateActivistCount() { Geography selectedGeo = this.GeographyTree.SelectedGeography; int activistCount = Activists.GetCountForGeography(selectedGeo); string result = " No activist in " + selectedGeo.Name + ". Not even one! Nobody will receive your alert."; if (activistCount == 1) { result = " One activist in " + selectedGeo.Name + ". Just one. Hardly a mobilization, eh?"; } else if (activistCount > 1) { result = " " + activistCount.ToString() + " activists in " + selectedGeo.Name + "."; } this.LabelGeographies.Text = result; UpdateSmsCosts(); this.ButtonSend.Text = "Send (to " + activistCount.ToString() + ")"; }