Пример #1
0
        public async Task <IEnumerable <GovLocation_Dto> > Handle(GetMyGovLocations_Query request, CancellationToken cancellationToken)
        {
            //var userId = _currentUserService.UserId ?? string.Empty;

            // TODO Get current user's GovLocation ID - these are temporary for development
            int    myloc_id  = 13;
            string mylocCity = "City of Whittlesea";

            //var result = new List<GovLocation_Dto>();

            IEnumerable <GovLocation> govlocs = _context.GovLocations.AsEnumerable();

            var govLocations = await _context.GovLocations.ToListAsync();

            //GovLocation myloc = govlocs.Where(l => l.Id == myloc_id).FirstOrDefault();
            GovLocation myloc = govlocs.Where(l => l.Name == mylocCity).FirstOrDefault();

            IEnumerable <GovLocation> ancestors = GetAncestors(myloc);

            IEnumerable <GovLocation_Dto> result = null;

            if (ancestors != null)
            {
                result = _mapper.Map <List <GovLocation_Dto> >(ancestors);
            }
            return(result);
        }
Пример #2
0
        private static Govbody AddGovbody(string name, GovLocation loc)
        {
            Govbody gov = new Govbody(name, loc);

            _context.Govbodies.Add(gov);
            _context.SaveChanges();
            return(gov);
        }
Пример #3
0
        }                      // for EF

        public Govbody(string name, GovLocation parentLocation, int id = 0)
        {
            Guard.Against.NullOrEmpty(name, nameof(name));
            Guard.Against.Null(parentLocation, nameof(parentLocation));

            Name           = name;
            ParentLocation = parentLocation;

            Id = id;  // TODO - Remove this. It's a kludge to get a test working.
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <int?> Handle(RegisterGovLocation_Cmd request, CancellationToken cancellationToken)
        {
            //var entity = new GovLocation(request.Name, request.Type, request.Code);
            var entity = new GovLocation(request.Name, request.Type, null);

            _context.GovLocations.Add(entity);
            await _context.SaveChangesAsync(cancellationToken);

            return(entity.Id);
        }
Пример #5
0
        private Govbody AddGovbody(string name, GovLocation loc, string recordingsUrl = null)
        {
            Govbody gov = new Govbody(name, loc)
            {
                RecordingsUrl = recordingsUrl
            };

            _context.Govbodies.Add(gov);
            _context.SaveChanges();
            return(gov);
        }
Пример #6
0
        private static GovLocation AddLocation(string name, GovlocTypes type, GovLocation parent, string recordingsUrl = null)
        {
            GovLocation loc = new GovLocation(name, type, null)
            {
                ParentLocation = parent,
                RecordingsUrl  = recordingsUrl
            };

            _context.GovLocations.Add(loc);
            _context.SaveChanges();
            return(loc);
        }
Пример #7
0
        IEnumerable <GovLocation> GetAncestors(GovLocation loc)
        {
            yield return(loc);

            GovLocation parent = loc.ParentLocation;

            while (parent != null)
            {
                yield return(parent);

                parent = parent.ParentLocation;
            }
        }
Пример #8
0
        public static void Seed()
        {
            using (_context = GetLocalDbProvider())
            {
                // Check if the DB was already seeded.
                var query = from g in _context.GovLocations
                            where g.Name == "United States"
                            select g;
                var checkLoc = query.FirstOrDefault <GovLocation>();
                if (checkLoc != null)
                {
                    return;
                }

                GovLocation              country            = null;
                GovLocation              state              = null; // state or province
                GovLocation              county             = null;
                GovLocation              local              = null;
                Govbody                  council            = null;
                List <ElectedOfficial>   electedOfficials   = null;
                List <AppointedOfficial> appointedOfficials = null;

                ////////////////// Little Falls, NJ USA ////////////////////////////

                country = AddLocation("United States", GovlocTypes.Country, null);
                state   = AddLocation("New Jersey", GovlocTypes.StateOrProvince, country);
                county  = AddLocation("Passaic County", GovlocTypes.County, state);

                AddGovbody("Board of Freeholders", county);
                local   = AddLocation("Little Falls", GovlocTypes.Township, county, "https://www.youtube.com/channel/UCnXmZfXIxB9n_b6PMoh0kmA/videos");
                council = AddGovbody("City Council", local);

                electedOfficials = new List <ElectedOfficial>()
                {
                    new ElectedOfficial()
                    {
                        Name = "James Damiano", Title = "Mayor"
                    },
                    new ElectedOfficial()
                    {
                        Name = "Anthony Sgobba", Title = "President, Councilman"
                    },
                    new ElectedOfficial()
                    {
                        Name = "Albert Kahwaty", Title = "Councilman"
                    },
                    new ElectedOfficial()
                    {
                        Name = "Christopher Vancheri", Title = "Councilman"
                    },
                    new ElectedOfficial()
                    {
                        Name = "Christine Hablitz", Title = "Councilwoman"
                    },
                    new ElectedOfficial()
                    {
                        Name = "Tanya Seber", Title = "Councilwoman"
                    }
                };
                AddElectedOfficials(electedOfficials, council);

                appointedOfficials = new List <AppointedOfficial>()
                {
                    new AppointedOfficial()
                    {
                        Name = "Charles Cuccia", Title = "Township Administrator"
                    },
                    new AppointedOfficial()
                    {
                        Name = "Cynthia Kraus, RMC", Title = "Township Clerk"
                    },
                    new AppointedOfficial()
                    {
                        Name = "Steven Post", Title = "Chief of Police"
                    },
                    new AppointedOfficial()
                    {
                        Name = "Richard Hamilton", Title = "Tax Assessor"
                    },
                    new AppointedOfficial()
                    {
                        Name = "James Di Maria", Title = "Construction Official"
                    },
                    new AppointedOfficial()
                    {
                        Name = "Charles Cuccia", Title = "CMFO/Treasurer"
                    },
                    new AppointedOfficial()
                    {
                        Name = "John E. Biegel III", Title = "Health Officer"
                    },
                    new AppointedOfficial()
                    {
                        Name = "Ronald Campbell", Title = "DPW Superintendent"
                    },
                };
                AddAppointedOfficials(appointedOfficials, council);

                AddGovbody("Zoning Board", local);

                /////////////////// City of Whittlesea & City of Greater Bebdingo, Victoria, AU ///////////////////

                state  = AddLocation("Pennsylvania", GovlocTypes.StateOrProvince, country);
                county = AddLocation("Philadelphia County", GovlocTypes.County, state);
                local  = AddLocation("Philadelphia", GovlocTypes.City, county);
                AddGovbody("City Council", local);

                country = AddLocation("Australia", GovlocTypes.Country, null);
                state   = AddLocation("Victoria", GovlocTypes.StateOrProvince, country);
                local   = AddLocation("City of Whittlesea", GovlocTypes.City, state);
                AddGovbody("City Council", local);
                local = AddLocation("City of Greater Bebdingo", GovlocTypes.City, state, "https://www.youtube.com/user/CityOfGreaterBendigo/videos");
                AddGovbody("City Council", local);
            }
        }
Пример #9
0
        public void Seed()
        {
            // Check if the DB was already seeded.
            var query = from g in _context.GovLocations
                        where g.Name == "United States"
                        select g;
            var checkLoc = query.FirstOrDefault <GovLocation>();

            if (checkLoc != null)
            {
                return;
            }

            GovLocation              country            = null;
            GovLocation              state              = null; // state or province
            GovLocation              county             = null;
            GovLocation              local              = null;
            Govbody                  council            = null;
            List <ElectedOfficial>   electedOfficials   = null;
            List <AppointedOfficial> appointedOfficials = null;

            ////////////////// Little Falls, NJ USA ////////////////////////////

            country = AddLocation("United States", GovlocTypes.Country, null);
            state   = AddLocation("New Jersey", GovlocTypes.StateOrProvince, country);
            county  = AddLocation("Passaic County", GovlocTypes.County, state);

            AddGovbody("Board of Freeholders", county);
            local   = AddLocation("Little Falls", GovlocTypes.Township, county, "https://www.lfnj.com/");
            council = AddGovbody("City Council", local, "https://www.youtube.com/channel/UCnXmZfXIxB9n_b6PMoh0kmA/videos");

            electedOfficials = new List <ElectedOfficial>()
            {
                new ElectedOfficial()
                {
                    Name = "James Damiano", Title = "Mayor"
                },
                new ElectedOfficial()
                {
                    Name = "Anthony Sgobba", Title = "President, Councilman"
                },
                new ElectedOfficial()
                {
                    Name = "Albert Kahwaty", Title = "Councilman"
                },
                new ElectedOfficial()
                {
                    Name = "Christopher Vancheri", Title = "Councilman"
                },
                new ElectedOfficial()
                {
                    Name = "Christine Hablitz", Title = "Councilwoman"
                },
                new ElectedOfficial()
                {
                    Name = "Tanya Seber", Title = "Councilwoman"
                }
            };
            AddElectedOfficials(electedOfficials, council);

            appointedOfficials = new List <AppointedOfficial>()
            {
                new AppointedOfficial()
                {
                    Name = "Charles Cuccia", Title = "Township Administrator"
                },
                new AppointedOfficial()
                {
                    Name = "Cynthia Kraus, RMC", Title = "Township Clerk"
                },
                new AppointedOfficial()
                {
                    Name = "Steven Post", Title = "Chief of Police"
                },
                new AppointedOfficial()
                {
                    Name = "Richard Hamilton", Title = "Tax Assessor"
                },
                new AppointedOfficial()
                {
                    Name = "James Di Maria", Title = "Construction Official"
                },
                new AppointedOfficial()
                {
                    Name = "Charles Cuccia", Title = "CMFO/Treasurer"
                },
                new AppointedOfficial()
                {
                    Name = "John E. Biegel III", Title = "Health Officer"
                },
                new AppointedOfficial()
                {
                    Name = "Ronald Campbell", Title = "DPW Superintendent"
                },
            };
            AddAppointedOfficials(appointedOfficials, council);

            AddGovbody("Zoning Board", local);

            ////////////////// Boothbay Harbor, ME USA ////////////////////////////

            country = AddLocation("United States", GovlocTypes.Country, null);
            state   = AddLocation("Maine", GovlocTypes.StateOrProvince, country);
            county  = AddLocation("Lincoln County", GovlocTypes.County, state);

            local   = AddLocation("Boothbay Harbor", GovlocTypes.Township, county, "https://www.boothbayharbor.org/");
            council = AddGovbody("Board of Selectmen", local, "https://www.boothbaytv.com/on-demand");

            electedOfficials = new List <ElectedOfficial>()
            {
                new ElectedOfficial()
                {
                    Name = "Wendy Wolf", Title = "Selectperson"
                },
                new ElectedOfficial()
                {
                    Name = "Michael Tomko", Title = "Chair"
                },
                new ElectedOfficial()
                {
                    Name = "Denise Griffin ", Title = "Councilman"
                },
                new ElectedOfficial()
                {
                    Name = "Tricia Warren ", Title = "Vice Chair"
                }
            };
            AddElectedOfficials(electedOfficials, council);

            appointedOfficials = new List <AppointedOfficial>()
            {
                new AppointedOfficial()
                {
                    Name = "Michelle Farnham", Title = "Town Clerk"
                },
                new AppointedOfficial()
                {
                    Name = "Robert Hasch", Title = "Police Chief"
                },
                new AppointedOfficial()
                {
                    Name = "Julia Latter", Title = "Town Manager"
                },
                new AppointedOfficial()
                {
                    Name = "Jeff Lowell", Title = "Harbor Master"
                },
                new AppointedOfficial()
                {
                    Name = "Geoff Smith", Title = "Code Enforcement Officer"
                }
            };
            AddAppointedOfficials(appointedOfficials, council);

            AddGovbody("Planning Board", local);

            /////////////////// City of Whittlesea & City of Greater Bebdingo, Victoria, AU ///////////////////

            state  = AddLocation("Pennsylvania", GovlocTypes.StateOrProvince, country);
            county = AddLocation("Philadelphia County", GovlocTypes.County, state);
            local  = AddLocation("Philadelphia", GovlocTypes.City, county);
            AddGovbody("City Council", local);

            country = AddLocation("Australia", GovlocTypes.Country, null);
            state   = AddLocation("Victoria", GovlocTypes.StateOrProvince, country);
            local   = AddLocation("City of Whittlesea", GovlocTypes.City, state);
            AddGovbody("City Council", local);
            local = AddLocation("City of Greater Bebdingo", GovlocTypes.City, state, "https://www.bendigo.vic.gov.au/");
            AddGovbody("City Council", local, "https://www.youtube.com/user/CityOfGreaterBendigo/videos");
        }