- Timestamp:
- 11/27/08 17:19:51 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs
r826 r845 33 33 new dsHiveServerTableAdapters.ResourceTableAdapter(); 34 34 35 private Resource Convert(dsHiveServer.ResourceRow row) { 36 if (row != null) { 37 Resource resource = new Resource(); 38 39 resource.ResourceId = row.ResourceId; 40 resource.Name = row.Name; 41 42 return resource; 43 } else 44 return null; 45 } 46 47 private dsHiveServer.ResourceRow Convert(Resource resource, 48 dsHiveServer.ResourceRow row) { 49 if (resource != null && row != null) { 50 row.Name = resource.Name; 51 } 52 53 return row; 54 } 55 35 56 public void UpdateResource(Resource resource) { 36 57 if (resource != null) { … … 46 67 } 47 68 48 //missing 49 row.Name = "test"; 69 Convert(resource, row); 50 70 51 71 adapter.Update(data); … … 55 75 } 56 76 57 public ClientInfo GetResourceById(long resourceId) { 58 throw new NotImplementedException(); 77 public Resource GetResourceById(long resourceId) { 78 dsHiveServer.ResourceDataTable data = 79 adapter.GetDataById(resourceId); 80 if (data.Count == 1) { 81 dsHiveServer.ResourceRow row = 82 data[0]; 83 return Convert(row); 84 } else { 85 return null; 86 } 59 87 } 60 88 61 89 public ICollection<Resource> GetAllResources() { 62 throw new NotImplementedException(); 90 ICollection<Resource> allResources = 91 new List<Resource>(); 92 93 dsHiveServer.ResourceDataTable data = 94 adapter.GetData(); 95 96 foreach (dsHiveServer.ResourceRow row in data) { 97 allResources.Add(Convert(row)); 98 } 99 100 return allResources; 63 101 } 64 102 65 103 public bool DeleteResource(Resource resource) { 66 dsHiveServer.ResourceDataTable data = 67 adapter.GetDataById(resource.ResourceId); 104 if(resource != null) { 68 105 69 if (data.Count == 1) {70 dsHiveServer.ResourceRow row = data[0];106 dsHiveServer.ResourceDataTable data = 107 adapter.GetDataById(resource.ResourceId); 71 108 72 row.Delete(); 73 return adapter.Update(data) > 0; 74 } else { 75 return false; 109 if (data.Count == 1) { 110 dsHiveServer.ResourceRow row = data[0]; 111 112 row.Delete(); 113 return adapter.Update(data) > 0; 114 } 76 115 } 116 117 return false; 77 118 } 78 119
Note: See TracChangeset
for help on using the changeset viewer.