Пример #1
0
        private void InitializeForCountyAdmin()
        {
            DialogCredentialMessage.InnerHtml = "Your sign-in credentials allow only " +
                                                Counties.GetFullName(_SecureAdminPage.StateCode,
                                                                     _SecureAdminPage.CountyCode) + " local districts to be selected.";

            StateName.InnerHtml = States.GetName(_SecureAdminPage.StateCode);
            StateDropDownList.AddCssClasses("hidden");
            StateRadioButton.AddCssClasses("invisible");
            CountyName.InnerHtml = Counties.GetName(_SecureAdminPage.StateCode,
                                                    _SecureAdminPage.CountyCode);
            CountyDropDownList.AddCssClasses("hidden");
            LocalName.AddCssClasses("hidden");

            switch (_SecureAdminPage.AdminPageLevel)
            {
            case AdminPageLevel.County:
                CountyRadioButton.Checked = true;
                PopulateLocalDropDown(true);
                break;

            case AdminPageLevel.Local:
                LocalRadioButton.Checked = true;
                PopulateLocalDropDown();
                break;
            }
        }
Пример #2
0
        static async Task SaveCountiesToDbAsync(Counties counties)
        {
            using (FloridaCountiesDbContext dbContext = InitDb()) {
                Console.WriteLine("Cleaning Counties table...");
                await dbContext.Database.ExecuteSqlRawAsync(@"DELETE FROM tblCounties");

                //Cascade deletion ensures cities are deleted as well

                Console.Write("Saving data to the DB...");
                dbContext.Counties.AddRange(counties.features.Select(feature => new FloridaCounty()
                {
                    Id      = int.Parse(feature.attributes.COUNTY),
                    DepCode = feature.attributes.DEPCODE,
                    EsriId  = feature.attributes.OBJECTID,
                    Name    = feature.attributes.COUNTYNAME != "DADE" ? feature.attributes.COUNTYNAME : "MIAMI-DADE",
                    Shape   = feature.geometry
                }));
                await dbContext.SaveChangesAsync();

                Console.WriteLine("COMPLETE.");

                Console.Write("Parsing cities....");
                IEnumerable <FloridaCity> cities = PopulateCitiesFromJsonFile(dbContext);
                dbContext.AddRange(cities);
                Console.WriteLine("COMPLETE.");

                Console.Write("Saving cities to DB....");
                await dbContext.SaveChangesAsync();

                Console.WriteLine("COMPLETE.");

                Console.WriteLine(" DONE!");
            }
        }
        private void AnalyzeDeletions(string address)
        {
            var found = false;

            found |= AnalyzeCount(States.CountByEmail(address), address, "States.Email");
            found |= AnalyzeCount(States.CountByAltEmail(address), address, "States.AltEmail");
            found |= AnalyzeCount(Counties.CountByEmail(address), address, "Counties.Email");
            found |= AnalyzeCount(Counties.CountByAltEmail(address), address, "Counties.AltEmail");
            found |= AnalyzeCount(LocalDistricts.CountByEmail(address), address, "LocalDistricts.Email");
            found |= AnalyzeCount(LocalDistricts.CountByAltEmail(address), address,
                                  "LocalDistricts.AltEmail");
            found |= AnalyzeCount(Politicians.CountByEmail(address), address, "Politicians.Email");
            found |= AnalyzeCount(Politicians.CountByCampaignEmail(address), address,
                                  "Politicians.CampaignEmail");
            found |= AnalyzeCount(Politicians.CountByEmailVoteUSA(address), address,
                                  "Politicians.EmailVoteUSA");
            found |= AnalyzeCount(Politicians.CountByStateEmail(address), address,
                                  "Politicians.StateEmail");
            //found |= AnalyzeCount(Politicians.CountByLDSEmail(address), address, "Politicians.LDSEmail");
            found |= AnalyzeCount(Addresses.EmailExists(address) ? 1 : 0, address, "Addresses.Email");
            found |= AnalyzeCount(PartiesEmails.PartyEmailExists(address) ? 1 : 0, address,
                                  "PartiesEmails.PartyEmail");
            if (!found)
            {
                _Messages.Add($"<p class=\"error\">{address} not found</p>");
            }
        }
Пример #4
0
        static Counties PopulateCountiesFromJsonFile()
        {
            Counties fileContent = null;

            using (StreamReader jsonStreamReader = File.OpenText(COUNTIES_JSON_DATAFILE)) {
                using (JsonTextReader jsonTextReader = new JsonTextReader(jsonStreamReader)) {
                    jsonTextReader.SupportMultipleContent = false;
                    JsonSerializer jsonSerializer = new JsonSerializer();
                    while (jsonTextReader.Read())
                    {
                        if (jsonTextReader.TokenType == JsonToken.StartObject)
                        {
                            fileContent = jsonSerializer.Deserialize <Counties>(jsonTextReader);
                        }
                    }
                }
            }

            if (fileContent is null)
            {
                DisplayError($"Unable to parse json file: {COUNTIES_JSON_DATAFILE}");
            }
            else
            {
                Console.WriteLine($"Counties data has been parsed and loaded from {COUNTIES_JSON_DATAFILE}...");
            }

            return(fileContent);
        }
Пример #5
0
        private void SetSubHeading()
        {
            switch (AdminPageLevel)
            {
            case AdminPageLevel.President:
            case AdminPageLevel.PresidentTemplate:
            case AdminPageLevel.Federal:
                H2.InnerHtml = States.GetName(StateCode) + ", All States";
                break;

            case AdminPageLevel.State:
                H2.InnerHtml = "State Elections for " + States.GetName(StateCode);
                break;

            case AdminPageLevel.County:
                H2.InnerHtml = "County Elections for " +
                               Counties.GetFullName(StateCode, CountyCode);
                break;

            case AdminPageLevel.Local:
                H2.InnerHtml = "Local Elections for " +
                               LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey);
                int countyCount;
                if ((countyCount = FormatOtherCountiesMessage(MultiCountyMessage)) > 1)
                {
                    MultiCountyMessage.InnerText +=
                        $". Changes you make to elections will appear in {(countyCount == 2 ? "both" : "all")} counties.";
                }
                break;

            case AdminPageLevel.Unknown:
                H2.InnerHtml = "No Jurisdiction Selected";
                break;
            }
        }
Пример #6
0
        private void SetSubHeading()
        {
            switch (AdminPageLevel)
            {
            //case AdminPageLevel.President:
            //case AdminPageLevel.PresidentTemplate:
            //case AdminPageLevel.Federal:
            //  H2.InnerHtml = States.GetName(StateCode) + ", All States";
            //  break;

            case AdminPageLevel.AllStates:
                H2.InnerHtml = "Bulk Email for All States";
                break;

            case AdminPageLevel.State:
                H2.InnerHtml = "Bulk Email for " + States.GetName(StateCode);
                break;

            case AdminPageLevel.County:
                H2.InnerHtml = "Bulk Email for " +
                               Counties.GetFullName(StateCode, CountyCode);
                break;

            case AdminPageLevel.Local:
                H2.InnerHtml = "Bulk Email for " +
                               LocalDistricts.GetFullName(StateCode, CountyCode, LocalCode);
                break;

            case AdminPageLevel.Unknown:
                H2.InnerHtml = "No Jurisdiction Selected";
                break;
            }
        }
 /// <summary>
 /// Dependent type names of this entity
 /// </summary>
 public void DeleteChildren(DatabaseEntities dbContext)
 {
     foreach (var x in Counties.ToList())
     {
         x.DeleteFull(dbContext);
     }
 }
Пример #8
0
        // ReSharper restore UnassignedField.Global
        // ReSharper restore UnusedAutoPropertyAccessor.Global
        // ReSharper restore UnusedMethodReturnValue.Global
        // ReSharper restore UnusedMember.Global
        // ReSharper restore MemberCanBeProtected.Global
        // ReSharper restore MemberCanBePrivate.Global

        #endregion ReSharper restore

        #endregion Public

        #region Private

        private void SetCredentialMessage()
        {
            switch (UserSecurityClass)
            {
            case MasterSecurityClass:
                CredentialMessage.InnerHtml =
                    "Your sign-in credentials allow access to all bulk mail capabilities.";
                break;

            case StateAdminSecurityClass:
                CredentialMessage.InnerHtml =
                    "Your sign-in credentials permit bulk mailing to any " +
                    States.GetName(StateCode) + " recipients.";
                break;

            case CountyAdminSecurityClass:
                CredentialMessage.InnerHtml =
                    "Your sign-in credentials permit bulk mailing only to " +
                    Counties.GetFullName(StateCode, CountyCode) + " recipients.";
                break;

            case LocalAdminSecurityClass:
                CredentialMessage.InnerHtml =
                    "Your sign-in credentials permit bulk mailing only to " +
                    LocalDistricts.GetFullName(StateCode, CountyCode, LocalCode) +
                    " recipients.";
                break;

            default:
                throw new VoteException("Unexpected UserSecurityClass: " +
                                        UserSecurityClass);
            }
        }
Пример #9
0
        //private string GetOfficeKey()
        //{
        //  return SelectedOfficeKey.Value;
        //}

        private void SetCredentialMessage()
        {
            switch (UserSecurityClass)
            {
            case MasterSecurityClass:
                CredentialMessage.InnerHtml = IsSuperUser
            ? "Your sign-in credentials allow any election to be updated."
            : "Your sign-in credentials allow any federal, state, county or local election to be updated.";
                break;

            case StateAdminSecurityClass:
                CredentialMessage.InnerHtml = "Your sign-in credentials permit any " +
                                              States.GetName(StateCode) + " election to be updated.";
                break;

            case CountyAdminSecurityClass:
                CredentialMessage.InnerHtml = "Your sign-in credentials permit only " +
                                              Counties.GetFullName(StateCode, CountyCode) +
                                              " elections to be updated.";
                break;

            case LocalAdminSecurityClass:
                CredentialMessage.InnerHtml = "Your sign-in credentials permit only " +
                                              LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey) +
                                              " elections to be updated.";
                SelectJurisdictionButton.Visible = false;
                break;

            default:
                throw new VoteException("Unexpected UserSecurityClass: " +
                                        UserSecurityClass);
            }
        }
Пример #10
0
        private void SetSubHeading()
        {
            switch (AdminPageLevel)
            {
            //case AdminPageLevel.President:
            //case AdminPageLevel.PresidentTemplate:
            //case AdminPageLevel.Federal:
            //  H2.InnerHtml = States.GetName(StateCode) + ", All States";
            //  break;

            case AdminPageLevel.State:
                H2.InnerHtml = "State Offices for " + States.GetName(StateCode);
                break;

            case AdminPageLevel.County:
                H2.InnerHtml = "County Offices for " +
                               Counties.GetFullName(StateCode, CountyCode);
                break;

            case AdminPageLevel.Local:
                H2.InnerHtml = "Local Offices for " +
                               LocalDistricts.GetFullName(StateCode, CountyCode, LocalKey);
                FormatOtherCountiesMessage(MuliCountyMessage);
                break;

            case AdminPageLevel.Unknown:
                H2.InnerHtml = "No Jurisdiction Selected";
                break;
            }
        }
Пример #11
0
        private Control GenerateReportByJurisdiction(string stateCode, string countyCode, string localKey)
        {
            ReportContainer.ID           = "new-accordions";
            ReportContainer.ClientIDMode = ClientIDMode.Static;
            stateCode = stateCode.ToUpperInvariant();
            _DataManager.GetDataByJurisdiction(stateCode, countyCode, localKey);

            var issueLevelGroups = _DataManager.GetDataSubset()
                                   .GroupBy(row => new
            {
                IssueGroupId = row.IssueGroupId(),
                IssueId      = row.IssueId()
            })
                                   .ToList()
                                   .GroupBy(g => g.Key.IssueGroupId)
                                   .ToList()
                                   .GroupBy(g => g.First().First()
                                            .IssueLevel())
                                   .OrderBy(g => g.Key)
                                   .ToList();

            foreach (var issueLevelGroup in issueLevelGroups)
            {
                switch (issueLevelGroup.Key)
                {
                case Issues.IssueLevelAll:
                    OneReportSection(issueLevelGroup,
                                     "Questions Available to All Candidates");
                    break;

                case Issues.IssueLevelNational:
                    OneReportSection(issueLevelGroup,
                                     "Questions Available to U.S. President, U.S. House and U.S. Senate Candidates");
                    break;

                case Issues.IssueLevelState:
                    OneReportSection(issueLevelGroup,
                                     $"Questions Available to {StateCache.GetStateName(stateCode)}" +
                                     " Statewide, House and Senate Candidates");
                    break;

                case Issues.IssueLevelCounty:
                    OneReportSection(issueLevelGroup,
                                     $"Questions Available to {Counties.GetName(stateCode, countyCode)}" +
                                     $" ({stateCode}) Candidates");
                    break;

                case Issues.IssueLevelLocal:
                    OneReportSection(issueLevelGroup,
                                     $"Questions Available to {LocalDistricts.GetName(stateCode, localKey)}" +
                                     $" ({stateCode}) Candidates");
                    break;
                }
            }

            return(ReportContainer.AddCssClasses("issue-list-report accordion-container"));
        }
Пример #12
0
        static async Task Main(string[] args)
        {
            //await PopulateFromAPI();


            Counties counties = PopulateCountiesFromJsonFile();

            await SaveCountiesToDbAsync(counties);
        }
Пример #13
0
        private static void CheckForFatalCredentialingProblems(string usernameEntered)
        {
            switch (UserSecurityClass)
            {
            case MasterSecurityClass:
                // no additional info needed
                break;

            case StateAdminSecurityClass:
                if (!StateCache.IsValidStateCode(UserStateCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid StateCode");
                }
                break;

            case CountyAdminSecurityClass:
                if (!Counties.StateCodeCountyCodeExists(UserStateCode, UserCountyCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid CountyCode");
                }
                break;

            case LocalAdminSecurityClass:
                //if (!LocalDistricts.StateCodeCountyCodeLocalCodeExists(
                // UserStateCode, UserCountyCode, UserLocalCode))
                //  HandleCredentialingInconsistency(usernameEntered, "Invalid LocalCode");
                break;

            case PartySecurityClass:
                if (!Parties.PartyKeyExists(UserPartyKey))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid PartyKey");
                }
                break;

            case PoliticianSecurityClass:
                // no additional info needed --
                // they couldn't get this far without a valid politician key
                break;

            case DesignSecurityClass:
                if (!DomainDesigns.DomainDesignCodeExists(UserDesignCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid DesignCode");
                }
                break;

            case OrganizationSecurityClass:
                if (!Organizations.OrganizationCodeExists(UserOrganizationCode))
                {
                    HandleCredentialingInconsistency(
                        usernameEntered, "Invalid OrganizationCode");
                }
                break;
            }
        }
        /// <summary>
        /// Active Dependent type names of this object
        /// </summary>
        public List <string> DependentObjectNames()
        {
            var dependentObjects = new List <string>();

            if (Counties.Any())
            {
                dependentObjects.Add(typeof(County).Name);
            }
            return(dependentObjects.Distinct().ToList());
        }
        public async Task <ActionResult> SaveLibraryUser(LibraryUserViewModel viewModel)
        {
            if (viewModel.CountyIds != null && viewModel.CountyIds.Length > 0)
            {
                viewModel.County = viewModel.CountyIds[0];
            }
            if (viewModel.CountryIds != null && viewModel.CountryIds.Length > 0)
            {
                viewModel.Country = viewModel.CountryIds[0];
            }

            if (!ModelState.IsValid)
            {
                viewModel.Counties  = Counties.PopulateCountySelectList(viewModel.County);
                viewModel.Countries = Countries.PopulateCountrySelectList(viewModel.Country);
                return(View("LibraryUser", viewModel));
            }

            string currentCode = string.Empty;

            if (string.IsNullOrEmpty(viewModel.LibraryUserCode))
            {
                var insertResponse = await _libraryUserClient.Insert(viewModel.GetApiModel());

                if (!insertResponse.StatusIsSuccessful)
                {
                    AddResponseErrorsToModelState(insertResponse);
                }
                else
                {
                    //viewModel.Id = insertResponse.ResponseResult;
                    currentCode = insertResponse.ResponseResult;
                    TempData["SuccessMessage"] = "Record Inserted";
                }
            }
            else
            {
                currentCode = viewModel.LibraryUserCode;
                var response = await _libraryUserClient.Update(viewModel.GetApiModel());

                if (!response.StatusIsSuccessful)
                {
                    AddResponseErrorsToModelState(response);
                }
                else
                {
                    TempData["SuccessMessage"] = "Record Updated";
                }
            }

            viewModel.Counties  = Counties.PopulateCountySelectList(viewModel.County);
            viewModel.Countries = Countries.PopulateCountrySelectList(viewModel.Country);

            return(View("LibraryUser", viewModel));
        }
Пример #16
0
 public override void Start()
 {
     base.Start();
     try
     {
         SelectedCounty    = Counties.FirstOrDefault(x => x.Id == 0);
         SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == 0);
         SelectedWard      = Wards.FirstOrDefault(x => x.Id == 0);
     }
     catch { }
 }
Пример #17
0
        /// <summary>
        /// Dependent type names of this entity
        /// </summary>
        public void DeleteChildren(DatabaseEntities dbContext)
        {
            foreach (var x in Counties.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in StormwaterJurisdictions.ToList())
            {
                x.DeleteFull(dbContext);
            }
        }
Пример #18
0
        static CountyCache()
        {
            var table = Counties.GetAllCacheData();

            CountyNameDictionary =
                table.ToDictionary(row => MakeKey(row.StateCode, row.CountyCode),
                                   row => row.County, StringComparer.OrdinalIgnoreCase);

            CountiesByStateDictionary = table.GroupBy(row => row.StateCode)
                                        .ToDictionary(g => g.Key,
                                                      g => g.OrderBy(row => row.County, StringComparer.OrdinalIgnoreCase)
                                                      .Select(row => row.CountyCode)
                                                      .ToList()
                                                      .AsReadOnly());
        }
Пример #19
0
        /**
         * Read all county files
         */
        private void ReadCounties()
        {
            var selectedCounties = ReadSelectedCounties();

            //Read county files
            foreach (string filePath in Directory.EnumerateFiles(Configuration.GetSetting(Configuration.INPUT_DIRECTORY)))
            {
                County county = ReadCounty(filePath, selectedCounties);
                if (county != null)
                {
                    Counties.Add(county);
                }
            }
            CountiesRead?.Invoke();
        }
        /// <summary>
        /// Lookups the county by fips.
        /// </summary>
        /// <param name="countyFIPS">The county fips.</param>
        /// <param name="stateFIPS">The state fips.</param>
        /// <returns></returns>
        private static County LookupCountyByFIPS(string countyFIPS, string stateFIPS)
        {
            int cFips;

            if (int.TryParse(countyFIPS, out cFips))
            {
                int sFips;
                if (int.TryParse(stateFIPS, out sFips))
                {
                    string countyCode = String.Format("{0:D2}{1:D3}", sFips, cFips);
                    return(Counties.FirstOrDefault(c => c.CountyFIPS.Equals(countyCode)));
                }
            }
            return(null);
        }
Пример #21
0
        public static string GetSpreadsheetListHtml(bool all = false, int?id = null)
        {
            var table = all
        ? ElectionSpreadsheets.GetAllListData()
        : ElectionSpreadsheets.GetListDataByCompleted(false);

            if (table.Count == 0)
            {
                return("<div>No spreadsheets found</div>");
            }

            // get a dictionary of election descriptions
            var dictionary =
                Elections.GetElectionDescriptions(table.Select(recordStates =>
                                                               recordStates.ElectionKey));

            // append jurisdictions
            var mods = new List <KeyValuePair <string, string> >();

            foreach (var kvp in dictionary)
            {
                if (!Elections.IsStateElection(kvp.Key))
                {
                    var stateCode    = Elections.GetStateCodeFromKey(kvp.Key);
                    var jurisdiction = Elections.IsCountyElection(kvp.Key)
            ? Counties.GetCounty(stateCode, Elections.GetCountyCodeFromKey(kvp.Key))
            : LocalDistricts.GetLocalDistrict(stateCode, Elections.GetLocalKeyFromKey(kvp.Key));
                    mods.Add(new KeyValuePair <string, string>(kvp.Key, jurisdiction));
                }
            }

            foreach (var kvp in mods)
            {
                dictionary[kvp.Key] += ", " + kvp.Value;
            }

            return(Join(Empty,
                        table.OrderByDescending(r => r.UploadTime).Select(r =>
                                                                          $"<div data-completed=\"{r.Completed.ToString().ToLower()}\"" +
                                                                          $" data-id=\"{r.Id}\" data-rows=\"{r.Rows}\"" +
                                                                          $"{(r.Id == id ? " class=\"selected\"" : Empty)}>" +
                                                                          $"{r.Filename} ({r.UploadTime:d}: {dictionary[r.ElectionKey]}" +
                                                                          $"{(r.ElectionScope == "A" ? " et. al." : Empty)}" +
                                                                          $"{(r.JurisdictionScope == "S" ? ", state level only" : Empty)})</div>")));
        }
Пример #22
0
        private void initCommonData()
        {
            if (doOnce)
            {
                return;
            }
            doOnce = true;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            Counties.GetAllCounties();
            Debug.WriteLine(" -GetAllCounties time in millisec:" + sw.ElapsedMilliseconds);
            sw.Restart();
            Master.Lists.Clients.GetAllClients();
            Master.Lists.Users.GetAllUsers();
            Debug.WriteLine(" -GetAllClients & GetAllUsers time in millisec:" + sw.ElapsedMilliseconds);
        }
Пример #23
0
            protected override bool Update(object newValue)
            {
                switch (Page.AdminPageLevel)
                {
                case AdminPageLevel.State:
                    States.UpdateColumn(StatesColumn, newValue, Page.StateCode);
                    break;

                case AdminPageLevel.County:
                    Counties.UpdateColumn(CountiesColumn, newValue, Page.StateCode, Page.CountyCode);
                    break;

                case AdminPageLevel.Local:
                    LocalDistricts.UpdateColumnByStateCodeLocalKey(LocalDistrictsColumn, newValue,
                                                                   Page.StateCode, Page.LocalKey);
                    break;
                }
                return(true);
            }
Пример #24
0
 /// <summary>
 /// Check that data is valid.
 /// </summary>
 public override void CheckData()
 {
     base.CheckData();
     LocationSearchString = LocationSearchString.CheckSqlInjection();
     if (Counties.IsNotEmpty())
     {
         foreach (WebCounty county in Counties)
         {
             county.CheckData();
         }
     }
     if (Provinces.IsNotEmpty())
     {
         foreach (WebProvince province in Provinces)
         {
             province.CheckData();
         }
     }
 }
Пример #25
0
        private void DoDeletions(string address)
        {
            var found = false;

            found |= DeletionCount(States.UpdateEmailByEmail(Empty, address), address,
                                   "States.Email");
            found |= DeletionCount(States.UpdateAltEmailByAltEmail(Empty, address),
                                   address, "States.AltEmail");
            found |= DeletionCount(Counties.UpdateEmailByEmail(Empty, address), address,
                                   "Counties.Email");
            found |= DeletionCount(Counties.UpdateAltEmailByAltEmail(Empty, address),
                                   address, "Counties.AltEmail");
            found |= DeletionCount(LocalDistricts.UpdateEmailByEmail(Empty, address),
                                   address, "LocalDistricts.Email");
            found |= DeletionCount(LocalDistricts.UpdateAltEmailByAltEmail(Empty, address),
                                   address, "LocalDistricts.AltEmail");
            found |= DeletionCount(Politicians.UpdateEmailByEmail(null, address), address,
                                   "Politicians.Email");
            found |= DeletionCount(
                Politicians.UpdateCampaignEmailByCampaignEmail(Empty, address), address,
                "Politicians.CampaignEmail");
            found |= DeletionCount(
                Politicians.UpdateEmailVoteUSAByEmailVoteUSA(Empty, address), address,
                "Politicians.EmailVoteUSA");
            found |= DeletionCount(
                Politicians.UpdateStateEmailByStateEmail(Empty, address), address,
                "Politicians.StateEmail");
            if (Addresses.EmailExists(address))
            {
                Addresses.DeleteByEmail(address);
                found |= DeletionCount(1, address, "Addresses");
            }
            found |= DeletionCount(PartiesEmails.DeleteByPartyEmail(address), address,
                                   "PartiesEmails.PartyEmail");
            found |= DeletionCount(
                OrganizationContacts.UpdateEmailByEmail(Empty, address), address,
                "OrganizationContacts.Email");
            if (!found)
            {
                _Messages.Add($"<p class=\"error\">{address} not found</p>");
            }
        }
        /// <summary>
        /// Get counties from web service.
        /// </summary>
        private static void LoadCounties()
        {
            CountyList counties;

            if (Counties.IsNull())
            {
                // Get data from web service.
                counties = new CountyList();
                foreach (WebCounty webCounty in WebServiceClient.GetCounties())
                {
                    counties.Add(new County(webCounty.Id,
                                            webCounty.Name,
                                            webCounty.Identifier,
                                            webCounty.IsNumberSpecified,
                                            webCounty.Number,
                                            webCounty.IsCountyPart,
                                            webCounty.PartOfCountyId));
                }
                Counties = counties;
            }
        }
Пример #27
0
        private void AddLocalsMenu(Control ul)
        {
            // County Admins always see a local menu
            // Masters and State Admins see it if they are on a County or Local Admin page
            string stateCode  = null;
            string countyCode = null;

            if (SecurePage.IsCountyAdminUser ||
                ((SecurePage.IsMasterUser || SecurePage.IsStateAdminUser) &&
                 (SecurePage.IsCountyAdminPage || SecurePage.IsLocalAdminPage)))
            {
                stateCode  = SecurePage.GetViewStateStateCode();
                countyCode = SecurePage.GetViewStateCountyCode();
            }
            if ((stateCode != null) && (countyCode != null))
            {
                AddMenuItem(ul, Counties.GetCounty(stateCode, countyCode),
                            GetLocalsMenu(
                                "/admin?state={StateCode}&county={CountyCode}&local={LocalCode}",
                                stateCode, countyCode));
            }
        }
Пример #28
0
            protected override string GetCurrentValue()
            {
                switch (Page.AdminPageLevel)
                {
                case AdminPageLevel.State:
                    return
                        ((States.GetColumn(StatesColumn, Page.StateCode) ?? Empty).ToString());

                case AdminPageLevel.County:
                    return
                        ((Counties.GetColumn(CountiesColumn, Page.StateCode, Page.CountyCode) ??
                          Empty).ToString());

                case AdminPageLevel.Local:
                    return
                        ((LocalDistricts.GetColumnByStateCodeLocalKey(LocalDistrictsColumn,
                                                                      Page.StateCode, Page.LocalKey) ?? Empty).ToString());

                default:
                    return(null);
                }
            }
        public override void LoadFromStore(VMStore modelStore)
        {
            try
            {
                ContactAddress = JsonConvert.DeserializeObject <ClientContactAddressDTO>(modelStore.Store);
                PersonId       = ContactAddress.PersonId;
                Downloaded     = ContactAddress.Downloaded;
                Telephone      = ContactAddress.Phone;
                Landmark       = ContactAddress.Landmark;
                ContactId      = ContactAddress.ContactId;
                AddressId      = ContactAddress.AddressId;

                SelectedCounty    = Counties.FirstOrDefault(x => x.Id == 0);
                SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == 0);
                SelectedWard      = Wards.FirstOrDefault(x => x.Id == 0);

                if (ContactAddress.CountyId.HasValue && ContactAddress.CountyId.Value > 0)
                {
                    SelectedCounty = Counties.FirstOrDefault(x => x.Id == ContactAddress.CountyId);
                    GetSubCounties();
                }

                if (ContactAddress.SubCountyId.HasValue && ContactAddress.SubCountyId.Value > 0)
                {
                    SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == ContactAddress.SubCountyId);
                    GetWards();
                }

                if (ContactAddress.WardId.HasValue && ContactAddress.WardId.Value > 0)
                {
                    SelectedWard = Wards.FirstOrDefault(x => x.Id == ContactAddress.WardId);
                }
            }
            catch (Exception e)
            {
                Mvx.Error(e.Message);
            }
        }
Пример #30
0
        public void DataTable_ContainsRkiColumns()
        {
            var sut    = CreateExportDefinition();
            var county = Counties.First();

            Sending.SamplingLocation       = SamplingLocation.Other;
            Sending.OtherSamplingLocation  = "Other Location";
            Sending.Patient.BirthDate      = new DateTime(2005, 8, 31);
            Sending.Patient.County         = county.Name;
            Sending.Patient.State          = State.BB;
            Sending.Patient.Gender         = Gender.Female;
            Sending.Patient.HibVaccination = VaccinationStatus.Yes;
            Sending.Isolate.Evaluation     = Evaluation.HaemophilusTypeA;
            Sending.Isolate.BetaLactamase  = TestResult.Negative;

            var export = sut.ToDataTable(Sendings);

            export.Rows[0]["klhi_nr"].Should().Be(Sending.Isolate.StemNumber);
            export.Rows[0]["eing"].ToString().Should().Match("??.??.????");
            export.Rows[0]["ent"].ToString().Should().Match("??.??.????");
            export.Rows[0]["mat"].Should().Be("Other Location");
            export.Rows[0]["geb_monat"].Should().Be(8);
            export.Rows[0]["geb_jahr"].Should().Be(2005);
            export.Rows[0]["geschlecht"].Should().Be("w");
            export.Rows[0]["hib_impf"].Should().Be("Ja");
            export.Rows[0]["styp"].Should().Be("Hia");
            export.Rows[0]["b_lac"].Should().Be("negativ");
            export.Rows[0]["kreis_nr"].Should().Be(county.CountyNumber);
            export.Rows[0]["bundesland"].Should().Be("12");
            export.Rows[0]["einsender"].Should().Be(Sending.SenderId);
            export.Rows[0]["landkreis"].Should().Be(Sending.Patient.County);
            export.Rows[0]["bundeslandName"].Should().Be("Brandenburg");
            export.Rows[0]["ampicillinMHK"].Should().Be(2.0);
            export.Rows[0]["ampicillinBewertung"].Should().Be("resistent");
            export.Rows[0]["amoxicillinClavulansaeureMHK"].Should().Be(0.75);
            export.Rows[0]["bewertungAmoxicillinClavulansaeure"].Should().Be("sensibel");
        }