- Timestamp:
- 09/21/10 06:27:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs
r4442 r4455 21 21 22 22 using System.Collections.Generic; 23 using System.Data.Linq;24 23 using System.Linq; 25 24 using System.ServiceModel; … … 28 27 namespace HeuristicLab.Services.OKB { 29 28 /// <summary> 30 /// Implementation of <see cref="IAdminService"/>29 /// Implementation of the OKB administration service (interface <see cref="IAdminService"/>). 31 30 /// </summary> 32 31 [ServiceBehavior(IncludeExceptionDetailInFaults = true)] 33 32 public class AdminService : IAdminService { 34 33 #region Platform Methods 35 public Platform GetPlatform(long platformId) { 36 using (OKBDataContext okb = new OKBDataContext()) { 37 return okb.Platforms.FirstOrDefault(p => p.Id == platformId); 38 } 39 } 40 public IEnumerable<Platform> GetPlatforms() { 41 using (OKBDataContext okb = new OKBDataContext()) { 42 return okb.Platforms.ToArray(); 43 } 44 } 45 public void StorePlatform(Platform platform) { 46 using (OKBDataContext okb = new OKBDataContext()) { 47 Platform original = okb.Platforms.FirstOrDefault(p => p.Id == platform.Id); 48 if (original == null) { 49 okb.Platforms.InsertOnSubmit(new Platform() { 50 Name = platform.Name, 51 Description = platform.Description 52 }); 53 } else { 54 original.Name = platform.Name; 55 original.Description = platform.Description; 56 } 57 okb.SubmitChanges(); 58 } 59 } 60 public void DeletePlatform(long platformId) { 61 using (OKBDataContext okb = new OKBDataContext()) { 62 Platform platform = okb.Platforms.FirstOrDefault(p => p.Id == platformId); 63 if (platform != null) { 64 okb.Platforms.DeleteOnSubmit(platform); 65 okb.SubmitChanges(); 66 } 34 public DataTransfer.Platform GetPlatform(long id) { 35 using (OKBDataContext okb = new OKBDataContext()) { 36 return Convert.ToDto(okb.Platforms.FirstOrDefault(x => x.Id == id)); 37 } 38 } 39 public IEnumerable<DataTransfer.Platform> GetPlatforms() { 40 using (OKBDataContext okb = new OKBDataContext()) { 41 return okb.Platforms.Select(x => Convert.ToDto(x)).ToArray(); 42 } 43 } 44 public void StorePlatform(DataTransfer.Platform dto) { 45 using (OKBDataContext okb = new OKBDataContext()) { 46 DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == dto.Id); 47 if (entity == null) okb.Platforms.InsertOnSubmit(Convert.ToEntity(dto)); 48 else Convert.ToEntity(dto, entity); 49 okb.SubmitChanges(); 50 } 51 } 52 public void DeletePlatform(long id) { 53 using (OKBDataContext okb = new OKBDataContext()) { 54 DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == id); 55 if (entity != null) okb.Platforms.DeleteOnSubmit(entity); 56 okb.SubmitChanges(); 67 57 } 68 58 } … … 70 60 71 61 #region AlgorithmClass Methods 72 public AlgorithmClass GetAlgorithmClass(long algorithmClassId) { 73 using (OKBDataContext okb = new OKBDataContext()) { 74 return okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClassId); 75 } 76 } 77 public IEnumerable<AlgorithmClass> GetAlgorithmClasses() { 78 using (OKBDataContext okb = new OKBDataContext()) { 79 return okb.AlgorithmClasses.ToArray(); 80 } 81 } 82 public void StoreAlgorithmClass(AlgorithmClass algorithmClass) { 83 using (OKBDataContext okb = new OKBDataContext()) { 84 AlgorithmClass original = okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClass.Id); 85 if (original == null) { 86 okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() { 87 Name = algorithmClass.Name, 88 Description = algorithmClass.Description 89 }); 90 } else { 91 original.Name = algorithmClass.Name; 92 original.Description = algorithmClass.Description; 93 } 94 okb.SubmitChanges(); 95 } 96 } 97 public void DeleteAlgorithmClass(long algorithmClassId) { 98 using (OKBDataContext okb = new OKBDataContext()) { 99 AlgorithmClass algorithmClass = okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClassId); 100 if (algorithmClass != null) { 101 okb.AlgorithmClasses.DeleteOnSubmit(algorithmClass); 102 okb.SubmitChanges(); 103 } 62 public DataTransfer.AlgorithmClass GetAlgorithmClass(long id) { 63 using (OKBDataContext okb = new OKBDataContext()) { 64 return Convert.ToDto(okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id)); 65 } 66 } 67 public IEnumerable<DataTransfer.AlgorithmClass> GetAlgorithmClasses() { 68 using (OKBDataContext okb = new OKBDataContext()) { 69 return okb.AlgorithmClasses.Select(x => Convert.ToDto(x)).ToArray(); 70 } 71 } 72 public void StoreAlgorithmClass(DataTransfer.AlgorithmClass dto) { 73 using (OKBDataContext okb = new OKBDataContext()) { 74 DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == dto.Id); 75 if (entity == null) okb.AlgorithmClasses.InsertOnSubmit(Convert.ToEntity(dto)); 76 else Convert.ToEntity(dto, entity); 77 okb.SubmitChanges(); 78 } 79 } 80 public void DeleteAlgorithmClass(long id) { 81 using (OKBDataContext okb = new OKBDataContext()) { 82 DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id); 83 if (entity != null) okb.AlgorithmClasses.DeleteOnSubmit(entity); 84 okb.SubmitChanges(); 104 85 } 105 86 } … … 107 88 108 89 #region Algorithm Methods 109 public Algorithm GetAlgorithm(long algorithmId) { 110 using (OKBDataContext okb = new OKBDataContext()) { 111 return okb.Algorithms.FirstOrDefault(a => a.Id == algorithmId); 112 } 113 } 114 public IEnumerable<Algorithm> GetAlgorithms() { 115 using (OKBDataContext okb = new OKBDataContext()) { 116 return okb.Algorithms.ToArray(); 117 } 118 } 119 public void StoreAlgorithm(Algorithm algorithm) { 120 using (OKBDataContext okb = new OKBDataContext()) { 121 Algorithm original = okb.Algorithms.FirstOrDefault(a => a.Id == algorithm.Id); 122 if (original == null) { 123 okb.Algorithms.InsertOnSubmit(new Algorithm() { 124 Name = algorithm.Name, 125 Description = algorithm.Description, 126 PlatformId = algorithm.PlatformId, 127 AlgorithmClassId = algorithm.AlgorithmClassId 128 }); 129 } else { 130 original.Name = algorithm.Name; 131 original.Description = algorithm.Description; 132 original.PlatformId = algorithm.PlatformId; 133 original.AlgorithmClassId = algorithm.AlgorithmClassId; 134 } 135 okb.SubmitChanges(); 136 } 137 } 138 public void DeleteAlgorithm(long algorithmId) { 139 using (OKBDataContext okb = new OKBDataContext()) { 140 Algorithm algorithm = okb.Algorithms.FirstOrDefault(a => a.Id == algorithmId); 141 if (algorithm != null) { 142 okb.Algorithms.DeleteOnSubmit(algorithm); 143 okb.SubmitChanges(); 144 } 90 public DataTransfer.Algorithm GetAlgorithm(long id) { 91 using (OKBDataContext okb = new OKBDataContext()) { 92 return Convert.ToDto(okb.Algorithms.FirstOrDefault(x => x.Id == id)); 93 } 94 } 95 public IEnumerable<DataTransfer.Algorithm> GetAlgorithms() { 96 using (OKBDataContext okb = new OKBDataContext()) { 97 return okb.Algorithms.Select(x => Convert.ToDto(x)).ToArray(); 98 } 99 } 100 public void StoreAlgorithm(DataTransfer.Algorithm dto) { 101 using (OKBDataContext okb = new OKBDataContext()) { 102 DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == dto.Id); 103 if (entity == null) okb.Algorithms.InsertOnSubmit(Convert.ToEntity(dto)); 104 else Convert.ToEntity(dto, entity); 105 okb.SubmitChanges(); 106 } 107 } 108 public void DeleteAlgorithm(long id) { 109 using (OKBDataContext okb = new OKBDataContext()) { 110 DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == id); 111 if (entity != null) okb.Algorithms.DeleteOnSubmit(entity); 112 okb.SubmitChanges(); 145 113 } 146 114 } 147 115 #endregion 116 117 /* 148 118 149 119 /// <summary> … … 274 244 }); 275 245 } 276 } 246 }*/ 277 247 } 278 248 }
Note: See TracChangeset
for help on using the changeset viewer.