Esempio n. 1
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);
        }
Esempio n. 2
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);
        }