コード例 #1
0
        public ActionResultDTO DeleteProfile(int profileId)
        {
            var profile = ReadProfile(profileId);

            if (profile == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Image Profile Was Not Found", Id = 0
                }
            }
            ;
            _uow.ImageProfileRepository.Delete(profileId);

            _uow.Save();
            var computers       = _uow.ComputerRepository.Get(x => x.ImageProfileId == profileId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.ImageProfileId = -1;

                computerService.UpdateComputer(computer);
            }

            var groups       = _uow.GroupRepository.Get(x => x.ImageProfileId == profileId);
            var groupService = new GroupServices();

            foreach (var group in groups)
            {
                group.ImageProfileId = -1;
                groupService.UpdateGroup(group);
            }

            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.ImageProfileId == profileId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.ImageProfileId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }

            var actionResult = new ActionResultDTO();

            actionResult.Success = true;
            actionResult.Id      = profile.Id;

            return(actionResult);
        }
コード例 #2
0
        public ActionResultDTO DeleteRoom(int roomId)
        {
            var room = GetRoom(roomId);

            if (room == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Room Not Found", Id = 0
                }
            }
            ;
            _uow.RoomRepository.Delete(roomId);
            _uow.Save();

            var computers       = _uow.ComputerRepository.Get(x => x.RoomId == roomId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.RoomId = -1;

                computerService.UpdateComputer(computer);
            }

            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.RoomId == roomId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.RoomId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }

            var actionResult = new ActionResultDTO();

            actionResult.Success = true;
            actionResult.Id      = room.Id;
            return(actionResult);
        }
コード例 #3
0
        public ActionResultDTO DeleteBuilding(int buildingId)
        {
            var actionResult = new ActionResultDTO();
            var building     = GetBuilding(buildingId);

            if (building == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Building Not Found", Id = 0
                }
            }
            ;

            _uow.BuildingRepository.Delete(buildingId);
            _uow.Save();

            var computers       = _uow.ComputerRepository.Get(x => x.BuildingId == buildingId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.BuildingId = -1;

                computerService.UpdateComputer(computer);
            }

            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.BuildingId == buildingId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.BuildingId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }
            actionResult.Success = true;
            actionResult.Id      = buildingId;

            return(actionResult);
        }
コード例 #4
0
        public ActionResultDTO DeleteSite(int siteId)
        {
            var site = GetSite(siteId);

            if (site == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Site Not Found", Id = 0
                }
            }
            ;
            _uow.SiteRepository.Delete(siteId);
            _uow.Save();

            var computers       = _uow.ComputerRepository.Get(x => x.SiteId == siteId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.SiteId = -1;

                computerService.UpdateComputer(computer);
            }

            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.SiteId == siteId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.SiteId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }

            var actionResult = new ActionResultDTO();

            actionResult.Success = true;
            actionResult.Id      = site.Id;
            return(actionResult);
        }
コード例 #5
0
        public ActionResultDTO DeleteAlternateServerIp(int alternateServerIpId)
        {
            var alternateServerIp = GetAlternateServerIp(alternateServerIpId);

            if (alternateServerIp == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Alternate Server Ip Not Found", Id = 0
                }
            }
            ;
            _uow.AlternateServerIpRepository.Delete(alternateServerIpId);
            _uow.Save();
            var computers       = _uow.ComputerRepository.Get(x => x.AlternateServerIpId == alternateServerIpId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.AlternateServerIpId = -1;

                computerService.UpdateComputer(computer);
            }


            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.AlternateServerIpId == alternateServerIpId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.AlternateServerIpId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }
            var actionResult = new ActionResultDTO();

            actionResult.Success = true;
            actionResult.Id      = alternateServerIp.Id;
            return(actionResult);
        }
コード例 #6
0
        public ActionResultDTO DeleteImage(int imageId)
        {
            var image = GetImage(imageId);

            if (image == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Image Not Found", Id = 0
                }
            }
            ;
            var result = new ActionResultDTO();

            if (Convert.ToBoolean(image.Protected))
            {
                result.ErrorMessage = "This Image Is Protected And Cannot Be Deleted";

                return(result);
            }

            _uow.ImageRepository.Delete(image.Id);
            _uow.Save();
            result.Id = imageId;
            //Check if image name is empty or null, return if so or something will be deleted that shouldn't be
            if (string.IsNullOrEmpty(image.Name))
            {
                return(result);
            }

            var computers       = _uow.ComputerRepository.Get(x => x.ImageId == imageId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.ImageId        = -1;
                computer.ImageProfileId = -1;
                computerService.UpdateComputer(computer);
            }

            var groups       = _uow.GroupRepository.Get(x => x.ImageId == imageId);
            var groupService = new GroupServices();

            foreach (var group in groups)
            {
                group.ImageId        = -1;
                group.ImageProfileId = -1;
                groupService.UpdateGroup(group);
            }

            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.ImageId == imageId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.ImageId        = -1;
                groupProperty.ImageProfileId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }

            var delDirectoryResult = new FilesystemServices().DeleteImageFolders(image.Name);

            result.Success = delDirectoryResult;

            return(result);
        }
コード例 #7
0
        public ActionResultDTO DeleteClusterGroup(int clusterGroupId)
        {
            var clusterGroup = GetClusterGroup(clusterGroupId);

            if (clusterGroup == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Cluster Group Not Found", Id = 0
                }
            }
            ;
            _uow.ClusterGroupRepository.Delete(clusterGroupId);
            _uow.Save();

            var sites       = _uow.SiteRepository.Get(x => x.ClusterGroupId == clusterGroupId);
            var siteService = new SiteServices();

            foreach (var site in sites)
            {
                site.ClusterGroupId = -1;

                siteService.UpdateSite(site);
            }

            var buildings       = _uow.BuildingRepository.Get(x => x.ClusterGroupId == clusterGroupId);
            var buildingService = new BuildingServices();

            foreach (var building in buildings)
            {
                building.ClusterGroupId = -1;
                buildingService.UpdateBuilding(building);
            }

            var rooms       = _uow.RoomRepository.Get(x => x.ClusterGroupId == clusterGroupId);
            var roomService = new RoomServices();

            foreach (var room in rooms)
            {
                room.ClusterGroupId = -1;
                roomService.UpdateRoom(room);
            }

            var computers       = _uow.ComputerRepository.Get(x => x.ClusterGroupId == clusterGroupId);
            var computerService = new ComputerServices();

            foreach (var computer in computers)
            {
                computer.ClusterGroupId = -1;
                computerService.UpdateComputer(computer);
            }

            var groups       = _uow.GroupRepository.Get(x => x.ClusterGroupId == clusterGroupId);
            var groupService = new GroupServices();

            foreach (var group in groups)
            {
                group.ClusterGroupId = -1;
                groupService.UpdateGroup(group);
            }

            var groupProperties      = _uow.GroupPropertyRepository.Get(x => x.ClusterGroupId == clusterGroupId);
            var groupPropertyService = new GroupPropertyServices();

            foreach (var groupProperty in groupProperties)
            {
                groupProperty.ClusterGroupId = -1;
                groupPropertyService.UpdateGroupProperty(groupProperty);
            }

            var actionResult = new ActionResultDTO();

            actionResult.Success = true;
            actionResult.Id      = clusterGroup.Id;
            return(actionResult);
        }