Пример #1
0
        public bool UpdateFacility(Facility facility)
        {
            bool isUpdated = false;

            switch ((int)facility.FacilityTypes)
            {
            case 1:
                using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
                {
                    facility.Id = dataAccess.AddDwellingFacility(facility.ConvertToDwellingFacility(facility));
                    break;
                }

            case 2:
                using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
                {
                    facility.Id = dataAccess.AddLandFacility(facility.ConvertToLandFacility(facility));
                    break;
                }

            case 3:
                using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
                {
                    facility.Id = dataAccess.AddNonResidentialFacilities(facility.ConvertToNonResidentialFacility(facility));
                    break;
                }
            }
            return(isUpdated = true);
        }
Пример #2
0
        public bool DeleteFacility(Facility facility)
        {
            bool isDeleted = false;

            facility.Status = "Deleted";
            switch (facility.FacilityType)
            {
            case "Dwelling":
                using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
                {
                    dataAccess.UpdateDwellingFacility(facility.ConvertToDwellingFacility(facility));
                    break;
                }

            case "Land":
                using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
                {
                    dataAccess.UpdateLandFacility(facility.ConvertToLandFacility(facility));
                    break;
                }

            case "NonResidential":
                using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
                {
                    dataAccess.UpdateNonResidentialFacilities(facility.ConvertToNonResidentialFacility(facility));
                    break;
                }
            }
            return(isDeleted = true);
        }
Пример #3
0
        public Facility getFacilityById(int id, FacilityTypes facilityType)
        {
            Facility facility = new Facility();

            switch ((int)facilityType)
            {
            case 1:
                using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
                {
                    facility = facility.ConvertDBFacilityToFacility(dataAccess.GetDwellingFacilityById(id), null, null);
                    break;
                }

            case 2:
                using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
                {
                    facility = facility.ConvertDBFacilityToFacility(null, dataAccess.GetLandFacilityById(id), null);
                    break;
                }

            case 3:
                using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
                {
                    facility = facility.ConvertDBFacilityToFacility(null, null, dataAccess.GetNonResidentialFacilityById(id));
                    break;
                }
            }
            return(facility);
        }
Пример #4
0
        public List <Facility> GetAllFacilities()
        {
            List <Facility> facilities = new List <Facility>();
            Facility        facility   = new Facility();

            using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
            {
                var _facilities = facility.ConvertDwellingToFacility(dataAccess.GetDwellingFacilities());
                facilities.AddRange(_facilities);
            }

            using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
            {
                var _facilities = facility.ConvertLandToFacility(dataAccess.GetLandFacilities());
                facilities.AddRange(_facilities);
            }

            using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
            {
                var _facilities = facility.ConvertNonResidentialToFacility(dataAccess.GetNonResidentialFacilities());
                facilities.AddRange(_facilities);
            }
            return(facilities);
        }
Пример #5
0
        public List <FacilityType> GetFacilityZonings()
        {
            List <FacilityType> facilityTypes = new List <FacilityType>();

            using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
            {
                FacilityType facilityType = new FacilityType()
                {
                    Name            = "Dwellings",
                    FacilityZonings = new List <FacilityZoning>()
                };

                var dwellingFacilities = dataAccess.GetDwellingFacilities();
                var zonings            = dwellingFacilities.Select(d => d.Zoning.ToLower().Trim()).Distinct();
                foreach (var zoning in zonings)
                {
                    FacilityZoning facilityZoning = new FacilityZoning()
                    {
                        Name      = zoning,
                        SignedOff = dwellingFacilities.Where(d => d.Zoning.ToLower().Trim() == zoning.ToLower().Trim() && d.Status == (int)FacilityStatus.Completed).Count(),
                        Total     = dwellingFacilities.Where(d => d.Zoning.ToLower().Trim() == zoning.ToLower().Trim()).Count(),
                    };
                    facilityType.FacilityZonings.Add(facilityZoning);
                }
                facilityTypes.Add(facilityType);
            }

            using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
            {
                FacilityType facilityType = new FacilityType()
                {
                    Name            = "Land",
                    FacilityZonings = new List <FacilityZoning>()
                };

                var landFacilities = dataAccess.GetLandFacilities();
                var zonings        = landFacilities.Select(d => d.Zoning.ToLower().Trim()).Distinct();
                foreach (var zoning in zonings)
                {
                    FacilityZoning facilityZoning = new FacilityZoning()
                    {
                        Name      = zoning,
                        SignedOff = landFacilities.Where(d => d.Zoning.ToLower().Trim() == zoning.ToLower().Trim() && d.Status == (int)FacilityStatus.Completed).Count(),
                        Total     = landFacilities.Where(d => d.Zoning.ToLower().Trim() == zoning.ToLower().Trim()).Count()
                    };

                    facilityType.FacilityZonings.Add(facilityZoning);
                }
                facilityTypes.Add(facilityType);
            }

            using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
            {
                FacilityType facilityType = new FacilityType()
                {
                    Name            = "Non Residential Buildings",
                    FacilityZonings = new List <FacilityZoning>()
                };

                var nonResidentialFacilities = dataAccess.GetNonResidentialFacilities();
                var zonings = nonResidentialFacilities.Select(d => d.Zoning).Distinct();
                foreach (var zoning in zonings)
                {
                    FacilityZoning facilityZoning = new FacilityZoning()
                    {
                        Name      = zoning,
                        SignedOff = nonResidentialFacilities.Where(d => d.Zoning.ToLower().Trim() == zoning.ToLower().Trim() && d.Status == (int)FacilityStatus.Completed).Count(),
                        Total     = nonResidentialFacilities.Where(d => d.Zoning.ToLower().Trim() == zoning.ToLower().Trim()).Count()
                    };

                    facilityType.FacilityZonings.Add(facilityZoning);
                }
                facilityTypes.Add(facilityType);
            }
            return(facilityTypes);
        }
Пример #6
0
        public List <MapCoordinate> GetMapCoordinates()
        {
            List <MapCoordinate> mapCoordinates = new List <MapCoordinate>();

            using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
            {
                var dwellingFacilities = dataAccess.GetDwellingFacilities();
                foreach (var item in dwellingFacilities)
                {
                    if (!string.IsNullOrEmpty(item.GPSCoordinatesEast) && !string.IsNullOrEmpty(item.GPSCoordinatesSouth))
                    {
                        MapCoordinate mapCoordinate = new MapCoordinate()
                        {
                            Longitude    = item.GPSCoordinatesEast.Replace(",", "."),
                            Latitude     = item.GPSCoordinatesSouth.Replace(",", "."),
                            Description  = string.Format("Dwelling: {0} - {1}", item.ClientCode, item.Name),
                            FacilityId   = item.Id,
                            FacilityType = FacilityTypes.Dwellings
                        };
                        mapCoordinates.Add(mapCoordinate);
                    }
                }
            }

            using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
            {
                var landFacilities = dataAccess.GetLandFacilities();
                foreach (var item in landFacilities)
                {
                    if (!string.IsNullOrEmpty(item.GPSCoordinatesEast) && !string.IsNullOrEmpty(item.GPSCoordinatesSouth))
                    {
                        MapCoordinate mapCoordinate = new MapCoordinate()
                        {
                            Longitude    = item.GPSCoordinatesSouth,
                            Latitude     = item.GPSCoordinatesEast,
                            Description  = string.Format("Land: {0} - {1}", item.ClientCode, item.Name),
                            FacilityId   = item.Id,
                            FacilityType = FacilityTypes.Land
                        };
                        mapCoordinates.Add(mapCoordinate);
                    }
                }
            }

            using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
            {
                var nonResidentialFacilities = dataAccess.GetNonResidentialFacilities();
                foreach (var item in nonResidentialFacilities)
                {
                    if (!string.IsNullOrEmpty(item.GPSCoordinatesEast) && !string.IsNullOrEmpty(item.GPSCoordinatesSouth))
                    {
                        MapCoordinate mapCoordinate = new MapCoordinate()
                        {
                            Longitude    = item.GPSCoordinatesSouth,
                            Latitude     = item.GPSCoordinatesEast,
                            Description  = string.Format("Non Residential: {0} - {1}", item.ClientCode, item.Name),
                            FacilityId   = item.Id,
                            FacilityType = FacilityTypes.NonResidentialBuildings
                        };
                        mapCoordinates.Add(mapCoordinate);
                    }
                }
            }
            return(mapCoordinates);
        }
Пример #7
0
        public List <DashboardWedge> GetDashboardWedges()
        {
            List <DashboardWedge> list            = new List <DashboardWedge>();
            List <Facility>       facilities      = new List <Facility>();
            List <string>         dashboardWedges = new List <string>();

            dashboardWedges.Add("Number of properties");
            dashboardWedges.Add("Signed off properties");
            dashboardWedges.Add("Non Residential Buildings");
            dashboardWedges.Add("Dwellings");
            dashboardWedges.Add("Land");
            List <DataAccess.Tables.DwellingFacility>       dwellingFacilities       = new List <DataAccess.Tables.DwellingFacility>();
            List <DataAccess.Tables.LandFacility>           landFacilities           = new List <DataAccess.Tables.LandFacility>();
            List <DataAccess.Tables.NonResidentialFacility> nonResidentialFacilities = new List <DataAccess.Tables.NonResidentialFacility>();

            using (var dataAccess = new DataAccess.Repositories.DwellingFacilityRepository(appSettings.ConnectionString))
            {
                dwellingFacilities = dataAccess.GetDwellingFacilities();
            }

            using (var dataAccess = new DataAccess.Repositories.LandFacilityRepository(appSettings.ConnectionString))
            {
                landFacilities = dataAccess.GetLandFacilities();
            }

            using (var dataAccess = new DataAccess.Repositories.NonResidentialFacilityRepository(appSettings.ConnectionString))
            {
                nonResidentialFacilities = dataAccess.GetNonResidentialFacilities();
            }

            foreach (var wedge in dashboardWedges)
            {
                DashboardWedge dashboardWedge = new DashboardWedge();
                dashboardWedge.Name = wedge;
                if (dashboardWedge.Name == "Number of properties")
                {
                    dashboardWedge.Total = dwellingFacilities.Count();
                    dashboardWedge.Total = dashboardWedge.Total + landFacilities.Count();
                    dashboardWedge.Total = dashboardWedge.Total + nonResidentialFacilities.Count();
                }
                if (dashboardWedge.Name == "Signed off properties")
                {
                    dashboardWedge.Total = dwellingFacilities.Where(d => d.Status == (int)FacilityStatus.Completed).Count();
                    dashboardWedge.Total = dashboardWedge.Total + landFacilities.Where(d => d.Status == (int)FacilityStatus.Completed).Count();
                    dashboardWedge.Total = dashboardWedge.Total + nonResidentialFacilities.Where(d => d.Status == (int)FacilityStatus.Completed).Count();
                }
                if (dashboardWedge.Name == "Non Residential Buildings")
                {
                    dashboardWedge.Total = dwellingFacilities.Count();
                }

                if (dashboardWedge.Name == "Dwellings")
                {
                    dashboardWedge.Total = landFacilities.Count();
                }

                if (dashboardWedge.Name == "Land")
                {
                    dashboardWedge.Total = nonResidentialFacilities.Count();
                }

                list.Add(dashboardWedge);
            }
            return(list);
        }